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 ef90b0f

Browse filesBrowse files
Flarnatargos
authored andcommitted
test: verify tracing channel doesn't swallow unhandledRejection
Add a test to verify that TracingChannel.tracePromise doesn't swallow unhandledRejection events in case no then/catch handler is set by user. PR-URL: #59974 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 7b2032b commit ef90b0f
Copy full SHA for ef90b0f

File tree

Expand file treeCollapse file tree

1 file changed

+38
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+38
-0
lines changed
Open diff view settings
Collapse file
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const dc = require('diagnostics_channel');
5+
const assert = require('assert');
6+
7+
const channel = dc.tracingChannel('test');
8+
9+
const expectedError = new Error('test');
10+
const input = { foo: 'bar' };
11+
const thisArg = { baz: 'buz' };
12+
13+
process.on('unhandledRejection', common.mustCall((reason) => {
14+
assert.deepStrictEqual(reason, expectedError);
15+
}));
16+
17+
function check(found) {
18+
assert.deepStrictEqual(found, input);
19+
}
20+
21+
const handlers = {
22+
start: common.mustCall(check),
23+
end: common.mustCall(check),
24+
asyncStart: common.mustCall(check),
25+
asyncEnd: common.mustCall(check),
26+
error: common.mustCall((found) => {
27+
check(found);
28+
assert.deepStrictEqual(found.error, expectedError);
29+
})
30+
};
31+
32+
channel.subscribe(handlers);
33+
34+
// Set no then/catch handler to verify unhandledRejection happens
35+
channel.tracePromise(function(value) {
36+
assert.deepStrictEqual(this, thisArg);
37+
return Promise.reject(value);
38+
}, input, thisArg, expectedError);

0 commit comments

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