Skip to content

Commit

Permalink
http2: track async state for sending
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
addaleax authored and cjihrig committed Nov 6, 2017
1 parent f31b796 commit b50c334
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ Http2Session::Http2Session(Environment* env,
prep_->data = static_cast<void*>(this);
uv_prepare_start(prep_, [](uv_prepare_t* t) {
Http2Session* session = static_cast<Http2Session*>(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();
});
}
Expand Down

0 comments on commit b50c334

Please sign in to comment.