Skip to content

Commit 8b122c2

Browse files
committed
lib: fix diagnostics_channel lint issues
Refs: #63623 Refs: #63651 Signed-off-by: Divyanshu Sharma <divyanshu88999@gmail.com>
1 parent 83e403d commit 8b122c2

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

lib/diagnostics_channel.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const {
44
ArrayPrototypeAt,
5-
ArrayPrototypeIndexOf,
65
ArrayPrototypePush,
76
ArrayPrototypePushApply,
87
ArrayPrototypeSlice,
@@ -15,6 +14,7 @@ const {
1514
ReflectApply,
1615
SafeFinalizationRegistry,
1716
SafeMap,
17+
SafeSet,
1818
SymbolDispose,
1919
SymbolHasInstance,
2020
} = primordials;
@@ -60,7 +60,6 @@ function withSuppressionsContext(set, fn, thisArg, args) {
6060
if (storage) {
6161
return storage.run(set, () => ReflectApply(fn, thisArg, args));
6262
}
63-
// Fallback: just call the function without context
6463
return ReflectApply(fn, thisArg, args);
6564
}
6665
// Can't delete when weakref count reaches 0 as it could increment again.
@@ -164,7 +163,7 @@ class RunStoresScope {
164163
class ActiveChannel {
165164
subscribe(subscription, options = {}) {
166165
validateFunction(subscription, 'subscription');
167-
let suppressedBy = options && options.suppressedBy !== undefined ? options.suppressedBy : null;
166+
const suppressedBy = options && options.suppressedBy !== undefined ? options.suppressedBy : null;
168167
if (suppressedBy !== null) {
169168
const t = typeof suppressedBy;
170169
if (t === 'string' || t === 'number' || t === 'bigint' || t === 'boolean') {
@@ -709,19 +708,10 @@ function suppressed(key, fn, thisArg, ...args) {
709708
}
710709

711710
const storage = getSuppressionsStorage();
712-
let currentSet;
713-
if (storage) {
714-
currentSet = storage.getStore();
715-
}
716-
const next = currentSet ? new Set(currentSet) : new Set();
711+
const currentSet = storage ? storage.getStore() : undefined;
712+
const next = currentSet ? new SafeSet(currentSet) : new SafeSet();
717713
next.add(key);
718-
const wrapped = function() {
719-
try {
720-
console.error('diagnostics_channel: suppressed() executing callback');
721-
} catch (_) {}
722-
return ReflectApply(fn, thisArg, args);
723-
};
724-
return withSuppressionsContext(next, wrapped, thisArg, []);
714+
return withSuppressionsContext(next, fn, thisArg, args);
725715
}
726716

727717
module.exports = {

0 commit comments

Comments
 (0)