Skip to content

fix: Defer endpoint release while requests are in flight#693

Open
nyan-left wants to merge 2 commits intoGoogleChromeLabs:mainfrom
nyan-left:fix/gc-hang
Open

fix: Defer endpoint release while requests are in flight#693
nyan-left wants to merge 2 commits intoGoogleChromeLabs:mainfrom
nyan-left:fix/gc-hang

Conversation

@nyan-left
Copy link
Copy Markdown

Fixes #692

FinalizationRegistry cleanup currently closes the endpoint and clears pendingListeners without checking whether any are mid-flight, so a GC'd proxy during a long await silently drops the worker's reply and the awaiter hangs forever.

This patch defers the release while pendingListeners.size > 0 and runs it from the message handler once they drain. No public API change.

Includes a karma test that fails in 2s when src/comlink.ts is reverted, passes with the change applied. Self-skips when --js-flags=--expose-gc isn't available.

@nyan-left nyan-left changed the title Defer endpoint release while requests are in flight fix: Defer endpoint release while requests are in flight Apr 27, 2026
@nyan-left nyan-left marked this pull request as draft April 27, 2026 14:26
@nyan-left nyan-left marked this pull request as draft April 27, 2026 14:26
@nyan-left nyan-left marked this pull request as ready for review April 27, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-flight requests are silently dropped when the proxy is GC'd mid-await

1 participant