Skip to content

Commit 6d63705

Browse files
authored
Merge pull request #16296 from getsentry/ab/trpc-middleware-isolation-scope-forking
feat(node): Fork isolation scope in tRPC middleware
1 parent 12c90d1 commit 6d63705

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/core/src/trpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getClient, withScope } from './currentScopes';
1+
import { getClient, withIsolationScope } from './currentScopes';
22
import { captureException } from './exports';
33
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';
44
import { startSpanManual } from './tracing';
@@ -76,7 +76,7 @@ export function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {
7676
}
7777
}
7878

79-
return withScope(scope => {
79+
return withIsolationScope(scope => {
8080
scope.setContext('trpc', trpcContext);
8181
return startSpanManual(
8282
{

packages/core/test/lib/trpc.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('trpcMiddleware', () => {
2626
setExtra: vi.fn(),
2727
};
2828

29-
const withScope = vi.fn(callback => {
29+
const withIsolationScope = vi.fn(callback => {
3030
return callback(mockScope);
3131
});
3232

@@ -38,7 +38,7 @@ describe('trpcMiddleware', () => {
3838
client.init();
3939
vi.spyOn(currentScopes, 'getClient').mockReturnValue(mockClient);
4040
vi.spyOn(tracing, 'startSpanManual').mockImplementation((name, callback) => callback(mockSpan, () => {}));
41-
vi.spyOn(currentScopes, 'withScope').mockImplementation(withScope);
41+
vi.spyOn(currentScopes, 'withIsolationScope').mockImplementation(withIsolationScope);
4242
vi.spyOn(exports, 'captureException').mockImplementation(() => 'mock-event-id');
4343
});
4444

0 commit comments

Comments
 (0)