Add withCleanup function to @solana/plugin-core#1480
Conversation
🦋 Changeset detectedLatest commit: 20b3992 The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
BundleMonFiles updated (4)
Unchanged files (138)
Total files change +929B +0.19% Final result: ✅ View report in BundleMon website ➡️ |
|
Documentation Preview: https://kit-docs-omklur5iu-anza-tech.vercel.app |
lorisleiva
left a comment
There was a problem hiding this comment.
Very nice! Just a couple of nits. Is the idea that we only support sync dispose for now and if we need async support we can add withAsyncCleanup in the future?
118634a to
f07d644
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a152bf6 to
8676a63
Compare
Adds a `withCleanup` function that wraps any client with a synchronous `Symbol.dispose` method, enabling the TC39 `using` declaration pattern. Note that only synchronous cleanup is supported for now — async teardown (`Symbol.asyncDispose`) is not yet handled. If the client already has a `Symbol.dispose`, the new cleanup is chained so both run when the client is disposed. Includes unit tests and a type test.
8676a63 to
20b3992
Compare
|
We discussed offline, and decided to keep broadly this design. I've refactored this PR to use a This does add some state to the client object, which is maintained in a non-enumerable |
lorisleiva
left a comment
There was a problem hiding this comment.
Nice! The disposable stack API is great!
|
🔎💬 Inkeep AI search and chat service is syncing content for source 'Solana Kit Docs' |

Adds a
withCleanupfunction that extends any client with a synchronousSymbol.disposemethod, enabling the TC39usingdeclaration pattern. Note that only synchronous cleanup is supported for now — async teardown (Symbol.asyncDispose) is not yet handled. If the client already has aSymbol.dispose, the new cleanup is chained so both run when the client is disposed. Includes unit tests and a type test.