Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 04007f2

Browse filesBrowse files
theanarkhruyadorno
authored andcommitted
lib: fix diagnostics channel
PR-URL: #44154 Fixes: #44143 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
1 parent 6b84451 commit 04007f2
Copy full SHA for 04007f2

File tree

Expand file treeCollapse file tree

2 files changed

+9
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-14
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-diagnostics-channel-http-server-start.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-diagnostics-channel-http-server-start.js
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@ const dc = require('diagnostics_channel');
66
const assert = require('assert');
77
const http = require('http');
88

9-
const incomingStartChannel = dc.channel('http.server.request.start');
10-
const outgoingFinishChannel = dc.channel('http.server.response.finish');
11-
129
const als = new AsyncLocalStorage();
1310
let context;
1411

1512
// Bind requests to an AsyncLocalStorage context
16-
incomingStartChannel.subscribe(common.mustCall((message) => {
13+
dc.subscribe('http.server.request.start', common.mustCall((message) => {
1714
als.enterWith(message);
1815
context = message;
1916
}));
2017

2118
// When the request ends, verify the context has been maintained
2219
// and that the messages contain the expected data
23-
outgoingFinishChannel.subscribe(common.mustCall((message) => {
20+
dc.subscribe('http.server.response.finish', common.mustCall((message) => {
2421
const data = {
2522
request,
2623
response,
Collapse file

‎test/parallel/test-diagnostics-channel-http.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-diagnostics-channel-http.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,24 @@ const http = require('http');
55
const net = require('net');
66
const dc = require('diagnostics_channel');
77

8-
const onClientRequestStart = dc.channel('http.client.request.start');
9-
const onClientResponseFinish = dc.channel('http.client.response.finish');
10-
const onServerRequestStart = dc.channel('http.server.request.start');
11-
const onServerResponseFinish = dc.channel('http.server.response.finish');
12-
138
const isHTTPServer = (server) => server instanceof http.Server;
149
const isIncomingMessage = (object) => object instanceof http.IncomingMessage;
1510
const isOutgoingMessage = (object) => object instanceof http.OutgoingMessage;
1611
const isNetSocket = (socket) => socket instanceof net.Socket;
1712

18-
onClientRequestStart.subscribe(common.mustCall(({ request }) => {
13+
dc.subscribe('http.client.request.start', common.mustCall(({ request }) => {
1914
assert.strictEqual(isOutgoingMessage(request), true);
2015
}));
2116

22-
onClientResponseFinish.subscribe(common.mustCall(({ request, response }) => {
17+
dc.subscribe('http.client.response.finish', common.mustCall(({
18+
request,
19+
response
20+
}) => {
2321
assert.strictEqual(isOutgoingMessage(request), true);
2422
assert.strictEqual(isIncomingMessage(response), true);
2523
}));
2624

27-
onServerRequestStart.subscribe(common.mustCall(({
25+
dc.subscribe('http.server.request.start', common.mustCall(({
2826
request,
2927
response,
3028
socket,
@@ -36,7 +34,7 @@ onServerRequestStart.subscribe(common.mustCall(({
3634
assert.strictEqual(isHTTPServer(server), true);
3735
}));
3836

39-
onServerResponseFinish.subscribe(common.mustCall(({
37+
dc.subscribe('http.server.response.finish', common.mustCall(({
4038
request,
4139
response,
4240
socket,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.