Skip to content

Commit 31facf1

Browse files
committed
make sure we're popping the right scope
1 parent fd07776 commit 31facf1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ function wrapEndMethod(origEnd: ResponseEndMethod): WrappedResponseEndMethod {
134134
}
135135

136136
// now that our work is done, we can pop off the scope and allow the response to end
137-
currentHub.popScope();
137+
if (currentHub.getScope()?.getParent() === this.__sentryScope) {
138+
currentHub.popScope();
139+
} else {
140+
logger.warn('Found incorrect scope when popping. Please report this to the Sentry team.');
141+
}
142+
138143
return origEnd.call(this, ...args);
139144
};
140145
}

0 commit comments

Comments
 (0)