Version
main
Platform
Subsystem
diagnostics_channel
What steps will reproduce the bug?
import { channel, subscribe } from 'node:diagnostics_channel';
import { DatabaseSync } from 'node:sqlite';
const ch = channel('sqlite.db.query');
const db = new DatabaseSync(':memory:');
console.log('before:', ch.hasSubscribers);
try {
subscribe('sqlite.db.query', null);
} catch (error) {
console.log('caught:', error.code);
}
console.log('after:', ch.hasSubscribers);
// This query enters the unnecessarily installed native trace callback.
db.exec('SELECT 1');
db.close();
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The invalid callback should be rejected before the channel becomes active or native modules are notified, and hasSubscribers should remain false.
What do you see instead?
before: false
caught: ERR_INVALID_ARG_TYPE
after: true
A rejected subscription changes hasSubscribers from false to true even though no callback was installed.
Additional information
No response
Version
main
Platform
Subsystem
diagnostics_channel
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The invalid callback should be rejected before the channel becomes active or native modules are notified, and
hasSubscribersshould remainfalse.What do you see instead?
A rejected subscription changes
hasSubscribersfromfalsetotrueeven though no callback was installed.Additional information
No response