Skip to content

Commit 51c016f

Browse files
fix(integrations): Don't add empty stack trace in RewriteFrames (#5625)
This patch avoids adding an empty stack trace when a stack trace is not defined in the `RewriteFrames` integration. Co-authored-by: Abhijeet Prasad <[email protected]>
1 parent 232964c commit 51c016f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
This release adds an environment check in `@sentry/nextjs` for Vercel deployments (using the `VERCEL_ENV` env variable), and only enables `SentryWebpackPlugin` if the environment is `production`. To override this, [setting `disableClientWebpackPlugin` or `disableServerWebpackPlugin` to `false`](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#disable-sentrywebpackplugin) now takes precedence over other checks, rather than being a no-op. Note: Overriding this is not recommended! It can increase build time and clog Release Health data in Sentry with inaccurate noise.
88

9+
- fix(integrations): Don't add empty stack trace in `RewriteFrames` (#5625)
910
- fix(nextjs): Don't run webpack plugin on non-prod Vercel deployments (#5603)
1011

1112
## 7.11.1

packages/integrations/src/rewriteframes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class RewriteFrames implements Integration {
9797
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9898
values: event.exception!.values!.map(value => ({
9999
...value,
100-
stacktrace: this._processStacktrace(value.stacktrace),
100+
...(value.stacktrace && { stacktrace: this._processStacktrace(value.stacktrace) }),
101101
})),
102102
},
103103
};

packages/integrations/test/rewriteframes.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { RewriteFrames } from '../src/rewriteframes';
44

55
let rewriteFrames: RewriteFrames;
66
let exceptionEvent: Event;
7+
let exceptionWithoutStackTrace: Event;
78
let windowsExceptionEvent: Event;
89
let multipleStacktracesEvent: Event;
910

@@ -31,6 +32,11 @@ describe('RewriteFrames', () => {
3132
],
3233
},
3334
};
35+
exceptionWithoutStackTrace = {
36+
exception: {
37+
values: [{}],
38+
},
39+
};
3440
multipleStacktracesEvent = {
3541
exception: {
3642
values: [
@@ -64,6 +70,13 @@ describe('RewriteFrames', () => {
6470
expect(event.exception!.values![0].stacktrace!.frames![0].filename).toEqual('app:///file1.js');
6571
expect(event.exception!.values![0].stacktrace!.frames![1].filename).toEqual('app:///file2.js');
6672
});
73+
74+
it('ignore exception without StackTrace', () => {
75+
// @ts-ignore Validates that the Stacktrace does not exist before validating the test.
76+
expect(exceptionWithoutStackTrace.exception?.values[0].stacktrace).toEqual(undefined);
77+
const event = rewriteFrames.process(exceptionWithoutStackTrace);
78+
expect(event.exception!.values![0].stacktrace).toEqual(undefined);
79+
});
6780
});
6881

6982
describe('default iteratee prepends custom prefix to basename if frame starts with `/`', () => {

0 commit comments

Comments
 (0)