Skip to content

Commit

Permalink
http2: remove some unnecessary next ticks
Browse files Browse the repository at this point in the history
Backport-PR-URL: #20456
PR-URL: #19451
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
jasnell authored and MylesBorins committed May 15, 2018
1 parent da185ce commit e4c10e1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function onSettings() {
session[kUpdateTimer]();
debug(`Http2Session ${sessionName(session[kType])}: new settings received`);
session[kRemoteSettings] = undefined;
process.nextTick(emit, session, 'remoteSettings', session.remoteSettings);
session.emit('remoteSettings', session.remoteSettings);
}

// If the stream exists, an attempt will be made to emit an event
Expand All @@ -377,7 +377,7 @@ function onPriority(id, parent, weight, exclusive) {
const emitter = session[kState].streams.get(id) || session;
if (!emitter.destroyed) {
emitter[kUpdateTimer]();
process.nextTick(emit, emitter, 'priority', id, parent, weight, exclusive);
emitter.emit('priority', id, parent, weight, exclusive);
}
}

Expand All @@ -391,7 +391,7 @@ function onFrameError(id, type, code) {
`type ${type} on stream ${id}, code: ${code}`);
const emitter = session[kState].streams.get(id) || session;
emitter[kUpdateTimer]();
process.nextTick(emit, emitter, 'frameError', type, code, id);
emitter.emit('frameError', type, code, id);
}

function onAltSvc(stream, origin, alt) {
Expand All @@ -401,7 +401,7 @@ function onAltSvc(stream, origin, alt) {
debug(`Http2Session ${sessionName(session[kType])}: altsvc received: ` +
`stream: ${stream}, origin: ${origin}, alt: ${alt}`);
session[kUpdateTimer]();
process.nextTick(emit, session, 'altsvc', alt, origin, stream);
session.emit('altsvc', alt, origin, stream);
}

// Receiving a GOAWAY frame from the connected peer is a signal that no
Expand Down Expand Up @@ -731,7 +731,7 @@ function setupHandle(socket, type, options) {
// core will check for session.destroyed before progressing, this
// ensures that those at l`east get cleared out.
if (this.destroyed) {
process.nextTick(emit, this, 'connect', this, socket);
this.emit('connect', this, socket);
return;
}
debug(`Http2Session ${sessionName(type)}: setting up session handle`);
Expand Down Expand Up @@ -773,7 +773,7 @@ function setupHandle(socket, type, options) {
options.settings : {};

this.settings(settings);
process.nextTick(emit, this, 'connect', this, socket);
this.emit('connect', this, socket);
}

// Emits a close event followed by an error event if err is truthy. Used
Expand Down Expand Up @@ -1224,7 +1224,7 @@ class Http2Session extends EventEmitter {
}
}

process.nextTick(emit, this, 'timeout');
this.emit('timeout');
}

ref() {
Expand Down Expand Up @@ -1452,8 +1452,8 @@ function streamOnPause() {
function abort(stream) {
if (!stream.aborted &&
!(stream._writableState.ended || stream._writableState.ending)) {
process.nextTick(emit, stream, 'aborted');
stream[kState].flags |= STREAM_FLAGS_ABORTED;
stream.emit('aborted');
}
}

Expand Down Expand Up @@ -1575,7 +1575,7 @@ class Http2Stream extends Duplex {
}
}

process.nextTick(emit, this, 'timeout');
this.emit('timeout');
}

// true if the HEADERS frame has been sent
Expand Down

0 comments on commit e4c10e1

Please sign in to comment.