From b50c33470eeb74961fc75b884d6d88f028023a69 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 24 Oct 2017 23:25:02 +0200 Subject: [PATCH] http2: track async state for sending Sending pending data may involve running arbitrary JavaScript code. Therefore, it should involve a callback scope. PR-URL: https://github.com/nodejs/node/pull/16461 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann --- src/node_http2.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node_http2.cc b/src/node_http2.cc index 9c8f1293accb3d..9f5273c550600a 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -91,6 +91,12 @@ Http2Session::Http2Session(Environment* env, prep_->data = static_cast(this); uv_prepare_start(prep_, [](uv_prepare_t* t) { Http2Session* session = static_cast(t->data); + HandleScope scope(session->env()->isolate()); + Context::Scope context_scope(session->env()->context()); + + // Sending data may call arbitrary JS code, so keep track of + // async context. + InternalCallbackScope callback_scope(session); session->SendPendingData(); }); }