File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
packages/diagnostics_channel/src Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const {
4
- Channel,
5
4
channel
6
5
} = require ( 'diagnostics_channel' ) // eslint-disable-line n/no-restricted-require
7
6
8
7
const [ major , minor ] = process . versions . node . split ( '.' )
8
+ const channels = new WeakSet ( )
9
9
10
10
// Our own DC with a limited subset of functionality stable across Node versions.
11
11
// TODO: Move the rest of the polyfill here.
@@ -16,21 +16,23 @@ const dc = { channel }
16
16
// See https://github.com/nodejs/node/pull/47520
17
17
if ( major === '19' && minor === '9' ) {
18
18
dc . channel = function ( ) {
19
- const maybeInactive = channel . apply ( this , arguments )
19
+ const ch = channel . apply ( this , arguments )
20
20
21
- if ( maybeInactive . subscribe === Channel . prototype . subscribe ) {
22
- const subscribe = maybeInactive . subscribe
21
+ if ( ! channels . has ( ch ) ) {
22
+ const subscribe = ch . subscribe
23
23
24
- maybeInactive . subscribe = function ( ) {
25
- delete maybeInactive . subscribe
24
+ ch . subscribe = function ( ) {
25
+ delete ch . subscribe
26
26
27
27
subscribe . apply ( this , arguments )
28
28
29
- this . subscribe ( ( ) => { } ) // Keep it active forever.
29
+ subscribe ( ( ) => { } ) // Keep it active forever.
30
30
}
31
+
32
+ channels . add ( ch )
31
33
}
32
34
33
- return maybeInactive
35
+ return ch
34
36
}
35
37
}
36
38
You can’t perform that action at this time.
0 commit comments