Skip to content

feature request: improve error in case instrumented modules are loaded before dd-trace-js #6518

@JCMais

Description

@JCMais

Tracer Version(s)

5.67.0

Node.js Version(s)

24.8.0

Bug Report

After bumping to the latest version, I am seeing this on our logs:

TypeError: Cannot read properties of undefined (reading 'finish')
at WSReceiverPlugin.end (src/receiver.js:65:14)
at plugins/tracing.js:77:22
at wrappedHandler (plugins/plugin.js:81:24)
at Subscription._handler (plugins/plugin.js:15:9)
at Channel.publish (node:diagnostics_channel:143:9)
at node:diagnostics_channel:327:13
at run (node:diagnostics_channel:155:14)
at DatadogStorage.run (src/storage.js:79:22)
at node:diagnostics_channel:92:18
at Channel.runStores (node:diagnostics_channel:164:12)
at TracingChannel.traceSync (node:diagnostics_channel:317:18)
at WebSocket.wrappedMessageHandler (src/ws.js:75:23)
at WebSocket.emit (node:events:518:28)
at Receiver.receiverOnMessage (ws/lib/websocket.js:1220:20)
at Receiver.emit (node:events:518:28)
at Receiver.dataMessage (ws/lib/receiver.js:596:14)
at Receiver.getData (ws/lib/receiver.js:496:10)
at Receiver.startLoop (ws/lib/receiver.js:167:16)
at Receiver._write (ws/lib/receiver.js:94:10)
at writeOrBuffer (streams/writable:572:12)
at _write (streams/writable:501:10)
at Writable.write (streams/writable:510:10)

This is followed by the following error:

Error: Error in plugin handler:
at wrappedHandler (plugins/plugin.js:83:16)
at Subscription._handler (plugins/plugin.js:15:9)
at Channel.publish (node:diagnostics_channel:143:9)
at node:diagnostics_channel:327:13
at run (node:diagnostics_channel:155:14)
at DatadogStorage.run (src/storage.js:79:22)
at node:diagnostics_channel:92:18
at Channel.runStores (node:diagnostics_channel:164:12)
at TracingChannel.traceSync (node:diagnostics_channel:317:18)
at WebSocket.wrappedMessageHandler (src/ws.js:75:23)
at WebSocket.emit (node:events:518:28)
at Receiver.receiverOnMessage (ws/lib/websocket.js:1220:20)
at Receiver.emit (node:events:518:28)
at Receiver.dataMessage (ws/lib/receiver.js:596:14)
at Receiver.getData (ws/lib/receiver.js:496:10)
at Receiver.startLoop (ws/lib/receiver.js:167:16)
at Receiver._write (ws/lib/receiver.js:94:10)
at writeOrBuffer (streams/writable:572:12)
at _write (streams/writable:501:10)
at Writable.write (streams/writable:510:10)
at TLSSocket.socketOnData (ws/lib/websocket.js:1355:35)
at TLSSocket.emit (node:events:518:28)

My configuration is just calling tracer.init(). I do have opentelemetry loaded and configured before dd

Reproduction Code

literally just tracer.init()

profiling is disabled
runtime metrics are enabled

Error Logs

No response

Tracer Config

No response

Operating System

No response

Bundling

No Bundling

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions