From 1e3b395ed422996cb1db5bd03a49bd6a3b7e798a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 21 Nov 2017 12:39:55 +0100 Subject: [PATCH] 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. --- src/node_http2.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index b439ae588a7756..52883dcd644bfc 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -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(data)->Done(false); + }, static_cast(ping)); } Stop();