Skip to content

Commit

Permalink
http2: don't call into JS from GC
Browse files Browse the repository at this point in the history
Calling into JS land from GC is not allowed, so delay
the resolution of pending pings when a session is destroyed.
  • Loading branch information
addaleax committed Nov 21, 2017
1 parent d5033aa commit 1e3b395
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ void Http2Session::Close() {

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

Stop();
Expand Down

0 comments on commit 1e3b395

Please sign in to comment.