Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,28 @@ jobs:
working-directory: dev-packages/node-integration-tests
run: yarn test

job_node_v18_compat:
name: Node v18.0.0 Compatibility Check
needs: [job_get_metadata, job_build]
if: needs.job_build.outputs.changed_node == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v6
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '18.0.0'
- name: Restore caches
uses: ./.github/actions/restore-cache
with:
dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check Node v18.0.0 compatibility
run: node scripts/node-v18-compat-check.js

job_node_core_integration_tests:
name:
Node (${{ matrix.node }})${{ (matrix.typescript && format(' (TS {0})', matrix.typescript)) || '' }} Node-Core
Expand Down Expand Up @@ -1198,6 +1220,7 @@ jobs:
job_deno_unit_tests,
job_node_unit_tests,
job_node_integration_tests,
job_node_v18_compat,
job_node_core_integration_tests,
job_cloudflare_integration_tests,
job_bun_integration_tests,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tracingChannel } from 'node:diagnostics_channel';
import * as diagnosticsChannel from 'node:diagnostics_channel';
import type { IntegrationFn, Span } from '@sentry/core';
import {
debug,
Expand Down Expand Up @@ -73,7 +73,7 @@ const _mysqlChannelIntegration = (() => {
name: INTEGRATION_NAME,
setupOnce() {
DEBUG_BUILD && debug.log(`[orchestrion:mysql] subscribing to channel "${CHANNELS.MYSQL_QUERY}"`);
const queryCh = tracingChannel(CHANNELS.MYSQL_QUERY);
const queryCh = diagnosticsChannel.tracingChannel(CHANNELS.MYSQL_QUERY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The change to a namespace import introduces a runtime TypeError on Node.js <18.19.0 when mysqlChannelIntegration is used, as diagnosticsChannel.tracingChannel will be undefined.
Severity: MEDIUM

Suggested Fix

Add a runtime check to ensure diagnosticsChannel.tracingChannel is a function before calling it. This will prevent the TypeError on older Node.js versions where the API does not exist, effectively guarding the integration's setup.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/integrations/tracing-channel/mysql.ts#L76

Potential issue: The change from a named import to a namespace import (`import * as
diagnosticsChannel`) prevents a load-time crash on Node.js versions below 18.19.0.
However, it introduces a new runtime bug. On these older Node versions,
`diagnosticsChannel.tracingChannel` is `undefined`. When the `mysqlChannelIntegration`
is initialized, its `setupOnce()` method is called, which attempts to execute
`diagnosticsChannel.tracingChannel(...)`. This results in a `TypeError:
diagnosticsChannel.tracingChannel is not a function`, crashing the application at
runtime during SDK initialization.

Also affects:

  • packages/node-core/src/integrations/pino.ts:130
  • packages/opentelemetry/src/tracingChannel.ts:56

Did we get this right? 👍 / 👎 to inform future reviews.


// Each `context` object is shared across start/end/asyncStart/asyncEnd/error
// for one call (orchestrion creates one per invocation). We key the span
Expand Down
7 changes: 7 additions & 0 deletions scripts/node-v18-compat-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// Verify the Node SDK can be loaded without errors on Node v18.0.0 (the minimum supported version).
// This catches accidental use of Node APIs that don't exist in v18.0.0.
require('@sentry/node');

console.log('Node v18.0.0 compatibility check passed');
Loading