Skip to content

Commit ed5c1aa

Browse files
committed
fixup! http: improve performance by removing async_hooks
1 parent 447db0b commit ed5c1aa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ function resOnFinish(req, res, socket, state, server) {
996996
// If the user never called req.read(), and didn't pipe() or
997997
// .resume() or .on('data'), then we call req._dump() so that the
998998
// bytes will be pulled off the wire.
999-
if (!req._consuming && !req._readableState.resumeScheduled)
999+
if (!req._consuming && !req._readableState.resumeScheduled && !req._readableState.paused)
10001000
req._dump();
10011001

10021002
res.detachSocket(socket);

src/node_http_parser.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ class Parser : public BaseObject, public StreamListener {
464464

465465
Local<Value> buffer = Buffer::Copy(env, at, length).ToLocalChecked();
466466

467-
MaybeLocal<Value> r =
468-
cb.As<Function>()->Call(env->context(), object(), 1, &buffer);
467+
v8::TryCatch try_catch(env->isolate());
468+
USE(cb.As<Function>()->Call(env->context(), object(), 1, &buffer));
469469

470-
if (r.IsEmpty()) {
470+
if (try_catch.HasCaught()) {
471471
got_exception_ = true;
472472
llhttp_set_error_reason(&parser_, "HPE_JS_EXCEPTION:JS Exception");
473473
return HPE_USER;
@@ -503,9 +503,11 @@ class Parser : public BaseObject, public StreamListener {
503503
if (!cb->IsFunction())
504504
return 0;
505505

506-
MaybeLocal<Value> r =
507-
cb.As<Function>()->Call(env()->context(), object(), 0, nullptr);
508-
if (r.IsEmpty()) {
506+
507+
v8::TryCatch try_catch(env()->isolate());
508+
USE(cb.As<Function>()->Call(env()->context(), object(), 0, nullptr));
509+
510+
if (try_catch.HasCaught()) {
509511
got_exception_ = true;
510512
return -1;
511513
}

0 commit comments

Comments
 (0)