Skip to content

Comments

Capture strong ref to internal stream in internal.c++#6148

Merged
jasnell merged 1 commit intomainfrom
jasnell/capture-ref-internal
Feb 24, 2026
Merged

Capture strong ref to internal stream in internal.c++#6148
jasnell merged 1 commit intomainfrom
jasnell/capture-ref-internal

Conversation

@jasnell
Copy link
Collaborator

@jasnell jasnell commented Feb 24, 2026

In some edge cases, the this can be collected while the promise is still pending. Capture a strong ref to keep it alive.

In some edge cases, the `this` can be collected while
the promise is still pending. Capture a strong ref
to keep it alive.
@jasnell jasnell requested review from a team as code owners February 24, 2026 03:55
@ask-bonk
Copy link

ask-bonk bot commented Feb 24, 2026

The analysis is thorough and conclusive. The error handlers are safe because JSG bundles both the success and error callbacks into a single ThenCatchPair that shares a common V8 GC-traced lifetime. The ref captured in the success handler keeps this alive for both paths.

LGTM

github run

@codspeed-hq

This comment was marked as outdated.

@jasnell jasnell merged commit 3e8427b into main Feb 24, 2026
25 checks passed
@jasnell jasnell deleted the jasnell/capture-ref-internal branch February 24, 2026 13:55
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.

2 participants