fix(plugin): scope Promise event iterators - #42832
Open
thdxr wants to merge 1 commit into
Open
Conversation
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.
Summary
Stream.toAsyncIterablebridge with one child Effect scope and scoped queue per async iteratornext()calls resolve terminally and buffered events cannot escape after unloadsubscribe()callsDesign
Stream.toAsyncIterablecreates an internal unsafe scope per iterator, but that scope is only closed by the iterator's ownreturn(). Tracking those iterators initially looked sufficient, but Effect v4 can blockreturn()behind a pendingnext()on a never-ending source.The adapter now uses
Stream.toQueueinside a child scope forked from the plugin generation. Consumer return closes and detaches that child; plugin replacement, unload, failed-load cleanup, and parent shutdown close it through normal Effect scope ownership. A LIFO child finalizer marks the wrapper terminal before queue shutdown wakes pending takes.Tests
next()next()calls remain terminalfor awaitbreak releases the Bus subscriptionbun testinpackages/pluginbun test test/plugin/promise.test.ts test/plugin.test.tsinpackages/corebun typecheckinpackages/pluginVerification Note
bun typecheckinpackages/coreand the pre-push repository-wide typecheck are currently blocked by unrelated baseline DOM typing errors forHeaders,Request, andResponse; the pre-push Turbo process also exited with SIGSEGV. The affected plugin package typecheck and focused core tests pass.