Skip to content

Commit 56dd734

Browse files
addaleaxMylesBorins
authored andcommitted
http2: track async state for sending
Sending pending data may involve running arbitrary JavaScript code. Therefore, it should involve a callback scope. PR-URL: #16461 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent e578268 commit 56dd734

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node_http2.cc

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ Http2Session::Http2Session(Environment* env,
9191
prep_->data = static_cast<void*>(this);
9292
uv_prepare_start(prep_, [](uv_prepare_t* t) {
9393
Http2Session* session = static_cast<Http2Session*>(t->data);
94+
HandleScope scope(session->env()->isolate());
95+
Context::Scope context_scope(session->env()->context());
96+
97+
// Sending data may call arbitrary JS code, so keep track of
98+
// async context.
99+
InternalCallbackScope callback_scope(session);
94100
session->SendPendingData();
95101
});
96102
}

0 commit comments

Comments
 (0)