Repository navigation
Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/node
SDK Version
10.21.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Sentry.init({
dsn: SENTRY_DSN,
attachStacktrace: true,
integrations: [
Sentry.captureConsoleIntegration({ levels: ['error'] }),
Sentry.extraErrorDataIntegration({ captureErrorCause: true }),
],
...
})Steps to Reproduce
We are observing the behaviour in our node express app.
Log only a message (i.e. not containing an Error object) so captureMessage is called via the captureConsoleIntegration.
console.error('Some error happened here')Expected Result
A stacktrace including a frame with the file and lineno where the console.error is called - for example (note this is an example from the client app where stacktraces are working)
null: Some error happened here
at captureMessage(../../../node_modules/@sentry/core/src/exports.ts:44:28)
at callback(../../../node_modules/@sentry/core/src/integrations/captureconsole.ts:90:95)
at AsyncContextStack.withScope(../../../node_modules/@sentry/core/src/asyncContext/stackStrategy.ts:48:28)
at withScope(../../../node_modules/@sentry/core/src/asyncContext/stackStrategy.ts:134:33)
at withScope(../../../node_modules/@sentry/core/src/currentScopes.ts:65:14)
at consoleHandler(../../../node_modules/@sentry/core/src/integrations/captureconsole.ts:62:3)
at handler(../../../node_modules/@sentry/core/src/integrations/captureconsole.ts:43:9)
at triggerHandlers(../../../node_modules/@sentry/core/src/instrument/handlers.ts:58:68)
at error(../../../node_modules/@sentry/core/src/instrument/console.ts:36:9)
at initHelper(index.client.jsx:321:11)
at <anonymous>(index.client.jsx:529:5)
Actual Result
null: Some error happened here
File "/node_modules/@sentry/core/build/cjs/integrations/captureconsole.js", line 78, col 15
exports$1.captureMessage(message, captureContext);
File "/node_modules/@sentry/opentelemetry/build/cjs/index.js", line 1308, col 14
return callback(getCurrentScope());
File "node:internal/async_local_storage/async_hooks", line 91, col 14, in AsyncLocalStorage.run
File "/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js", line 33, col 40, in SentryContextManager.with
return this._asyncLocalStorage.run(context, cb, ...args);
File "/node_modules/@sentry/opentelemetry/build/cjs/index.js", line 1433, col 24, in SentryContextManager.with
return super.with(ctx2, fn, thisArg, ...args);
File "/node_modules/@opentelemetry/api/build/src/api/context.js", line 60, col 46, in ContextAPI.with
return this._getContextManager().with(context, fn, thisArg, ...args);
File "/node_modules/@sentry/opentelemetry/build/cjs/index.js", line 1307, col 28, in Object.withScope
return api.context.with(ctx, () => {
File "/node_modules/@sentry/core/build/cjs/currentScopes.js", line 61, col 14, in Module.withScope
return acs.withScope(rest[0]);
only sentry and internal frames.
Additional Context
- All the issues have the title
AsyncLocalStorage.run. - I think this might have started after upgrading from JS SDK v8 to v10 - it has affected multiple v10 versions (we've tried 10.11.0, 10.13.0, 10.22.0)
- Log calls with an
Errorin the args get a correct stacktrace - i.e. the stacktrace from the Error. - Log messages from the client (via @sentry/react) do get a correct stacktrace in the issue
- Using latest node v22
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
linear commentedon Nov 5, 2025
JS-1115
Lms24 commentedon Nov 5, 2025
Hey @md384 thanks for reporting! I could reproduce this and I found the reason for why the frame of the file is missing: Node by default limits the stack trace to the 10 top-most stack frames. The synthetic error we generate from within the SDK happens so late in the call stack that the 10 top-most frames are all part of the Sentry SDK and its dependencies/calls. I will investigate if we can create the synthetic error a bit earlier in the call stack of our
captureMessagecall to include the user code by default.As a workaround, you can set
to get longer stack traces. Once I did that, my file was included and also shown by Sentry as the in-app stack frame.
However, I still get
AsyncLocalStorage.runas the issue title which is a bit weird. I asked the issues team why this is happening and how we can improve this.github-actions commentedon Nov 19, 2025
A PR closing this issue has just been released 🚀
This issue was referenced by PR #18096, which was included in the 10.26.0 release.