Skip to content

diagnostics_channel: invalid sqlite.db.query subscription activates native tracing #65312

Description

@trivikr

Version

main

Platform

N/A

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

diagnostics_channelIssues and PRs related to the diagnostics_channel module.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions