-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
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
8.34.0
Framework Version
koa 2.15.3, @koa/router 13.1.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
instrument.ts
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: "mydns",
tracesSampleRate: 1.0,
integrations: [Sentry.koaIntegration()],
debug: true,
});
server.ts
import './instrument';
import Koa from 'koa';
import Router from '@koa/router';
import * as Sentry from '@sentry/node';
const app = new Koa();
const router = new Router();
Sentry.setupKoaErrorHandler(app);
function log(msg: string) {
const globalScope = Sentry.getGlobalScope().getScopeData();
const isolationScope = Sentry.getIsolationScope().getScopeData();
const currentScope = Sentry.getCurrentScope().getScopeData();
const data = {
...globalScope.tags,
...globalScope.extra,
...isolationScope.tags,
...isolationScope.extra,
...currentScope.tags,
...currentScope.extra,
};
console.info(msg, JSON.stringify(data));
}
router.get('/', (ctx) => {
log('BEFORE');
Sentry.setTag('query', ctx.request.query.test as string);
log('AFTER');
});
app.use(router.routes());
export const server = app.listen(8088, () => log('Server started on 8088'));
Steps to Reproduce
- Run
npx tsx server.ts
- Trigger the
/
endpoint with a GET request and a URL query parametertest
set tofoo
- Console outputs:
BEFORE {}
AFTER {"query":"foo"}
- Trigger the
/
endpoint again, but change query parameter value tofoo2
- Console outputs:
BEFORE {"query":"foo"}
AFTER {"query":"foo2"}
Expected Result
The expected result is that the Sentry tag query
is not persisted across consecutive incoming HTTP requests. Wrapping the /
handler with Sentry.withScope
does not fix this
In practice this means the second trigger should output:
BEFORE {}
AFTER {"query":"foo2"}
Actual Result
The second trigger outputs:
BEFORE {"query":"foo"}
AFTER {"query":"foo2"}
Metadata
Metadata
Assignees
Labels
Projects
Status
No status