Skip to content
Merged
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
6 changes: 3 additions & 3 deletions packages/node-core/src/integrations/pino.ts
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 { Integration, IntegrationFn, LogSeverityLevel } from '@sentry/core';
import {
_INTERNAL_captureLog,
Expand Down Expand Up @@ -122,8 +122,8 @@ const _pinoIntegration = defineIntegration((userOptions: DeepPartial<PinoOptions
},
});

const injectedChannel = tracingChannel('orchestrion:pino:pino-log');
const integratedChannel = tracingChannel('pino_asJson');
const injectedChannel = diagnosticsChannel.tracingChannel('orchestrion:pino:pino-log');
const integratedChannel = diagnosticsChannel.tracingChannel('pino_asJson');
Copy link

Choose a reason for hiding this comment

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

Bug: Import Change Hides tracingChannel Bug

Changing from named import to namespace import doesn't fix the missing tracingChannel export in Node <18.19.0. The code will now throw a runtime error (diagnosticsChannel.tracingChannel is not a function) when setup executes instead of an import-time error. This makes debugging harder and violates the documented Node version requirement without any runtime check or graceful fallback.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This integration is only supported on Node where tracingChannel is supported

Comment on lines +125 to +126
Copy link

Choose a reason for hiding this comment

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

Bug: Pino integration crashes on Node < 18.19.0 due to diagnosticsChannel.tracingChannel() being undefined.
Severity: CRITICAL | Confidence: 0.98

🔍 Detailed Analysis

The pino integration will crash with a "TypeError: diagnosticsChannel.tracingChannel is not a function" at runtime when its setup() function is called on Node versions < 18.19.0. This occurs because the code at lines 125-126 attempts to call diagnosticsChannel.tracingChannel() without checking if the method exists, as diagnosticsChannel.tracingChannel is undefined on these older Node versions. This unexpected crash violates the integration's documented Node version requirements.

💡 Suggested Fix

Implement version checks for diagnosticsChannel.tracingChannel() similar to SentryNodeFetchInstrumentation.ts to ensure it's only called on Node >= 18.19.0, or handle the undefined case gracefully by providing a fallback or no-op.

🤖 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/node-core/src/integrations/pino.ts#L125-L126

Potential issue: The pino integration will crash with a "TypeError:
diagnosticsChannel.tracingChannel is not a function" at runtime when its `setup()`
function is called on Node versions < 18.19.0. This occurs because the code at lines
125-126 attempts to call `diagnosticsChannel.tracingChannel()` without checking if the
method exists, as `diagnosticsChannel.tracingChannel` is `undefined` on these older Node
versions. This unexpected crash violates the integration's documented Node version
requirements.

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

Reference_id: 2618499


function onPinoStart(self: Pino, args: PinoHookArgs, result: PinoResult): void {
if (!shouldTrackLogger(self)) {
Expand Down