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?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
9.24.0
Framework Version
Node 22.14.0 LTS
Link to Sentry event
No response
Reproduction Example/SDK Setup
In line 81, a user context is attached to the isolation scope, but (unhandled) exception in line 90 didn't capture this information.
The following function is being called here: https://github.com/zhiyan114/Firey-Bot/blob/275621a29a3f4181857476fd0a002a83301d91e9/src/services/VoiceChatReward.ts#L35C4-L35C71
Steps to Reproduce
For minimal reproduction step, the following code should replicate the exact behavior:
- Use
withIsolationScope
withinsetTimeout
,setTimeout
, or equivalent.
import { init, captureException, consoleLoggingIntegration, extraErrorDataIntegration, flush, logger, rewriteFramesIntegration, withIsolationScope, withIsolationScope } from "@sentry/node";
function caller(bk: ()=> Promise<void>) {
setTimeout(bk, 1000);
}
process.env["SENTRY_RELEASE"] = execSync(`git -C ${__dirname} rev-parse HEAD`).toString().trim(),
init({
dsn: "someDSN",
maxValueLength: 1000,
tracesSampleRate: 0,
sendDefaultPii: true,
_experiments: {
// Enable logs to be sent to Sentry.
enableLogs: true,
},
integrations: [
extraErrorDataIntegration({
depth: 3
}),
consoleLoggingIntegration({ levels: ['log', 'error', 'warn'] }),
rewriteFramesIntegration({
iteratee(frame) {
const absPath = frame.filename;
if(!absPath) return frame;
frame.filename = `/${path.relative(__dirname, absPath).replace(/\\/g, "/")}`
return frame;
}
}),
],
beforeSend: (a,b) => {
console.log("Sending Error to Sentry...")
return a;
},
beforeBreadcrumb: (a,b) => {
console.log(`Sending Breadcrumb to Sentry: ${a.message}`)
return a;
},
beforeSendTransaction: () => null,
debug: true,
})
caller(async()=>{
await withIsolationScope(async (scope) => {
scope.setUser({
id: 0,
username: "ROOT",
Priv: "SuperUser"
})
console.log("HIII");
throw new Error("TESTING!!!!"); // setUser ctx will not be attached
//captureException(new Error("TESTING!!!!")); // setUser ctx will be attached
})
});
Expected Result
Unhandled exception are expected to attach user info context that's wrapped around by the withScope
Actual Result
The given context doesn't show up on the dashboard, the workaround is to force all errors to pass through captureException
(which then it wouldn't be unhandled).
Metadata
Metadata
Assignees
Type
Projects
Status
No status