Skip to content

fix(core): unbind all services in connection container on close#17384

Merged
cdamus merged 4 commits intomasterfrom
bugfix/17383-container-cleanup
Apr 23, 2026
Merged

fix(core): unbind all services in connection container on close#17384
cdamus merged 4 commits intomasterfrom
bugfix/17383-container-cleanup

Conversation

@cdamus
Copy link
Copy Markdown
Contributor

@cdamus cdamus commented Apr 21, 2026

What it does

Unbinds all services in the connection container on close of the socket. This lets @preDestroy hooks run in any singletons to clean up resources that they may have allocated.

Note that this does not interfere in any way with the timer-based reconnection strategy for fault-tolerant RPC connections. The container is only unbound once the connection is definitively closed. If a connection recovers from a brief outage, then all of the backend services will still be there ready to serve it.

Fixes #17383

How to test

Besides the included new automated test, add an @preDestroy clean-up method to some service bound in the backend in a connection-scoped container and do what is best to observe that it runs that clean-up when a frontend disconnects.

Follow-ups

None.

Breaking changes

  • This PR introduces breaking changes and requires careful review. If yes, the breaking changes section in the changelog has been updated.

Attribution

None.

Review checklist

Reminder for reviewers

Add a failing test case that will pass once the DefaultMessagingService
is updated to tear down the services bound in the child containers that
it creates for frontend connections' backend services.

Signed-off-by: Christian W. Damus <cdamus@eclipsesource.com>
Comment thread packages/core/src/node/messaging/default-messaging-service.ts Outdated
Unbind all services in the connection container on close of the socket.
This lets @preDestroy hooks run in any singletons to clean up resources
that they may have allocated.

Fixes #17383

Signed-off-by: Christian W. Damus <cdamus@eclipsesource.com>
@cdamus cdamus force-pushed the bugfix/17383-container-cleanup branch from 26eda61 to 4baba9a Compare April 22, 2026 14:04
Copy link
Copy Markdown
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any regressions, and I wouldn't expect any, given that Theia doesn't use Inversify lifecycle methods that trigger on unbinding widely (though I did find one preDestroy I hadn't seen before). Nevertheless, it might be worth adding a note in the changelog indicating this as a potentially breaking change, since we know that service aliases with the wrong combination of binding types and decorations could break a global service.

@github-project-automation github-project-automation Bot moved this from Waiting on reviewers to Needs merge in PR Backlog Apr 23, 2026
@cdamus
Copy link
Copy Markdown
Contributor Author

cdamus commented Apr 23, 2026

Thanks for the suggestion @colin-grant-work . Commit a6049eb adds a blurb to the changelog explaining how latent footguns may go off.

@cdamus cdamus requested a review from colin-grant-work April 23, 2026 16:08
@cdamus cdamus merged commit ff8893f into master Apr 23, 2026
10 checks passed
@cdamus cdamus deleted the bugfix/17383-container-cleanup branch April 23, 2026 17:10
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Apr 23, 2026
@github-actions github-actions Bot added this to the 1.71.0 milestone Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Singleton services in connection-scoped containers are never destroyed

2 participants