Skip to content

Commit d06ad0d

Browse files
addaleaxMylesBorins
authored andcommitted
http2: don't call into JS from GC
Calling into JS land from GC is not allowed, so delay the resolution of pending pings when a session is destroyed. Backport-PR-URL: #18050 PR-URL: #17183 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 7e68080 commit d06ad0d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_http2.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,11 @@ void Http2Session::Close() {
406406

407407
while (!outstanding_pings_.empty()) {
408408
Http2Session::Http2Ping* ping = PopPing();
409-
ping->Done(false);
409+
// Since this method may be called from GC, calling into JS directly
410+
// is not allowed.
411+
env()->SetImmediate([](Environment* env, void* data) {
412+
static_cast<Http2Session::Http2Ping*>(data)->Done(false);
413+
}, static_cast<void*>(ping));
410414
}
411415

412416
Stop();

0 commit comments

Comments
 (0)