Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/internal/http2/core.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,12 @@ const { Duplex } = require('stream');
const tls = require('tls');
const { setImmediate, setTimeout, clearTimeout } = require('timers');

const dc = require('diagnostics_channel');
const onClientSessionCreatedChannel = dc.channel('http2.client.session.created');
const onClientSessionFinishChannel = dc.channel('http2.client.session.finish');
const onClientStreamCreatedChannel = dc.channel('http2.client.stream.created');
const onClientStreamFinishChannel = dc.channel('http2.client.stream.finish');

const {
kIncomingMessage,
_checkIsHttpToken: checkIsHttpToken,
Expand DownExpand Up@@ -1183,6 +1189,12 @@ function closeSession(session, code, error) {
state.flags |= SESSION_FLAGS_DESTROYED;
state.destroyCode = code;

if (session instanceof ClientHttp2Session && onClientSessionFinishChannel.hasSubscribers) {
onClientSessionFinishChannel.publish({
session: session,
});
}

// Clear timeout and remove timeout listeners.
session.setTimeout(0);
session.removeAllListeners('timeout');
Expand DownExpand Up@@ -1872,6 +1884,13 @@ class ClientHttp2Session extends Http2Session {
} else {
onConnect();
}

if (onClientStreamCreatedChannel.hasSubscribers) {
onClientStreamCreatedChannel.publish({
stream: stream,
});
}

return stream;
}
}
Expand DownExpand Up@@ -1968,6 +1987,12 @@ function closeStream(stream, code, rstStreamStatus = kSubmitRstStream) {
stream.end();
}

if (stream instanceof ClientHttp2Stream && onClientStreamFinishChannel.hasSubscribers) {
onClientStreamFinishChannel.publish({
stream: stream,
});
}

if (rstStreamStatus !== kNoRstStream) {
const finishFn = finishCloseStream.bind(stream, code);
if (!ending || stream.writableFinished || code !== NGHTTP2_NO_ERROR ||
Expand DownExpand Up@@ -3399,6 +3424,12 @@ function connect(authority, options, listener) {
if (typeof listener === 'function')
session.once('connect', listener);

if (onClientSessionCreatedChannel.hasSubscribers) {
onClientSessionCreatedChannel.publish({
session: session,
});
}

return session;
}

Expand Down