Add withAsyncCleanup function to @solana/plugin-core#1482
Draft
mcintyre94 wants to merge 3 commits intomainfrom
Draft
Add withAsyncCleanup function to @solana/plugin-core#1482mcintyre94 wants to merge 3 commits intomainfrom
withAsyncCleanup function to @solana/plugin-core#1482mcintyre94 wants to merge 3 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: bd08f33 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 |
Member
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
BundleMonFiles updated (7)
Unchanged files (135)
Total files change +668B +0.14% Final result: ✅ View report in BundleMon website ➡️ |
Contributor
|
Documentation Preview: https://kit-docs-n22kzqqv2-anza-tech.vercel.app |
f07d644 to
e873a18
Compare
b1f635a to
865113b
Compare
e873a18 to
a152bf6
Compare
865113b to
cc92768
Compare
cc92768 to
6abb962
Compare
a152bf6 to
8676a63
Compare
2d7dcfd to
bfe954a
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.
Adds a `withAsyncCleanup` function that wraps any client with a `Symbol.asyncDispose` method, enabling the TC39 `await using` declaration pattern. The cleanup function is async, and if the client already has a `Symbol.asyncDispose` it is awaited after the new cleanup runs. If only `Symbol.dispose` is present, it is called synchronously as a fallback. Includes unit tests and type tests.
bfe954a to
bd08f33
Compare
8676a63 to
20b3992
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR follows up the previous one by adding
withAsyncCleanupto enable async cleanup functions and theawait usingsyntax.For async cleanup, we first await the given cleanup function. We then call the parent
AsyncDisposeif there is one, falling back to a parentDisposeif there is one. This means that on async cleanup we call the parent cleanup function, even if it is not async.This PR also uses types to try to force consumers to use async disposal if any plugin in the chain uses
withAsyncCleanup:withAsyncCleanupisDisposable, this is stripped and onlyAsyncDisposableis returnedwithCleanupisAsyncDisposable, then it is returned with its type unchanged, ie it isAsyncDisposableand notDisposable. This means that if you chain a plugin with sync disposal after one with async disposal, the returned client isAsyncDisposableonly.Note: We could decide not to ship this until we/someone else have an async use case, I think our wallet plugin will only need sync. But async is part of the same spec, and not having it would limit some future use cases.