Skip to content

Commit abebe62

Browse files
committed
ref: Update withIsolationScope to not pass current scope
1 parent 9730647 commit abebe62

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

packages/node-experimental/src/sdk/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export function withScope<T>(callback: (scope: Scope) => T): T {
3737
}
3838

3939
/**
40-
* Fork a scope from the current scope, and make it the current scope in the given callback.
41-
* Additionally, also setup a new isolation scope for the callback.
40+
* For a new isolation scope from the current isolation scope,
41+
* and make it the current isolation scope in the given callback.
4242
*/
43-
export function withIsolationScope<T>(callback: (scope: Scope, isolationScope: Scope) => T): T {
43+
export function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {
4444
const ctx = context.active();
4545
const currentScopes = getScopesFromContext(ctx);
4646
const scopes = currentScopes
@@ -53,7 +53,7 @@ export function withIsolationScope<T>(callback: (scope: Scope, isolationScope: S
5353
scopes.isolationScope = scopes.isolationScope.clone();
5454

5555
return context.with(setScopesOnContext(ctx, scopes), () => {
56-
return callback(getCurrentScope(), getIsolationScope());
56+
return callback(getIsolationScope());
5757
});
5858
}
5959

packages/node-experimental/test/integration/scope.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,16 @@ describe('Integration | Scope', () => {
353353
initialIsolationScope.setTag('tag1', 'val1');
354354
initialIsolationScope.setTag('tag2', 'val2');
355355

356+
const initialCurrentScope = Sentry.getCurrentScope();
357+
356358
const error = new Error('test error');
357359

358-
Sentry.withIsolationScope((_currentScope, newIsolationScope) => {
360+
Sentry.withIsolationScope(newIsolationScope => {
359361
newIsolationScope.setTag('tag4', 'val4');
360362
});
361363

362-
Sentry.withIsolationScope((currentScope, newIsolationScope) => {
363-
expect(Sentry.getCurrentScope()).toBe(currentScope);
364+
Sentry.withIsolationScope(newIsolationScope => {
365+
expect(Sentry.getCurrentScope()).not.toBe(initialCurrentScope);
364366
expect(Sentry.getIsolationScope()).toBe(newIsolationScope);
365367
expect(newIsolationScope).not.toBe(initialIsolationScope);
366368

@@ -402,13 +404,13 @@ describe('Integration | Scope', () => {
402404

403405
const error = new Error('test error');
404406

405-
Sentry.withIsolationScope((_currentScope, newIsolationScope) => {
407+
Sentry.withIsolationScope(newIsolationScope => {
406408
newIsolationScope.setTag('tag2', 'val2');
407409

408-
Sentry.withIsolationScope((_currentScope, newIsolationScope) => {
410+
Sentry.withIsolationScope(newIsolationScope => {
409411
newIsolationScope.setTag('tag3', 'val3');
410412

411-
Sentry.withIsolationScope((_currentScope, newIsolationScope) => {
413+
Sentry.withIsolationScope(newIsolationScope => {
412414
newIsolationScope.setTag('tag4', 'val4');
413415
});
414416

@@ -648,8 +650,8 @@ describe('Integration | Scope', () => {
648650

649651
const error = new Error('test error');
650652

651-
Sentry.withIsolationScope((currentScope, isolationScope) => {
652-
currentScope.setTag('tag2', 'val2a');
653+
Sentry.withIsolationScope(isolationScope => {
654+
Sentry.getCurrentScope().setTag('tag2', 'val2a');
653655
isolationScope.setTag('tag2', 'val2b');
654656
isolationScope.setTag('tag3', 'val3');
655657

packages/node-experimental/test/integration/transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('Integration | Transactions', () => {
181181

182182
Sentry.addBreadcrumb({ message: 'test breadcrumb 1', timestamp: 123456 });
183183

184-
Sentry.withIsolationScope((scope, isolationScope) => {
184+
Sentry.withIsolationScope(() => {
185185
Sentry.startSpan({ op: 'test op', name: 'test name', source: 'task', origin: 'auto.test' }, span => {
186186
Sentry.addBreadcrumb({ message: 'test breadcrumb 2', timestamp: 123456 });
187187

0 commit comments

Comments
 (0)