Skip to content

Commit 518e310

Browse files
authored
ref: Remove 'use strict' from the bundle (getsentry#2078)
* ref: Remove 'use strict' from the bundle * test: Fix unhandledrejection handling with non-error input
1 parent 8ea17ee commit 518e310

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

packages/browser/rollup.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const bundleConfig = {
5454
format: 'iife',
5555
name: 'Sentry',
5656
sourcemap: true,
57+
strict: false,
5758
},
5859
context: 'window',
5960
plugins: [

packages/browser/src/tracekit.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tslint:disable
22

3-
import { getGlobalObject, isError, isErrorEvent } from '@sentry/utils';
3+
import { getGlobalObject, isError, isErrorEvent, normalize } from '@sentry/utils';
44

55
/**
66
* @hidden
@@ -274,6 +274,9 @@ TraceKit._report = (function reportModuleWrapper() {
274274
var err = (e && (e.detail ? e.detail.reason : e.reason)) || e;
275275
var stack = TraceKit._computeStackTrace(err);
276276
stack.mechanism = 'onunhandledrejection';
277+
if (!stack.message) {
278+
stack.message = JSON.stringify(normalize(err))
279+
}
277280
_notifyHandlers(stack, true, err);
278281
}
279282

packages/browser/test/integration/test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,9 @@ for (var idx in frames) {
667667
},
668668
function(sentryData) {
669669
if (debounceAssertEventCount(sentryData, 1, done)) {
670+
// non-error rejections doesnt provide stacktraces so we can skip the assertion
670671
assert.equal(sentryData[0].exception.values[0].value, '"test"');
671672
assert.equal(sentryData[0].exception.values[0].type, 'UnhandledRejection');
672-
assert.equal(sentryData[0].exception.values[0].stacktrace, undefined);
673673
assert.equal(sentryData[0].exception.values[0].mechanism.handled, false);
674674
assert.equal(sentryData[0].exception.values[0].mechanism.type, 'onunhandledrejection');
675675
done();
@@ -696,9 +696,9 @@ for (var idx in frames) {
696696
},
697697
function(sentryData) {
698698
if (debounceAssertEventCount(sentryData, 1, done)) {
699-
assert.isAtMost(sentryData[0].exception.values[0].value.length, 303);
699+
// non-error rejections doesnt provide stacktraces so we can skip the assertion
700+
assert.equal(sentryData[0].exception.values[0].value.length, 253);
700701
assert.equal(sentryData[0].exception.values[0].type, 'UnhandledRejection');
701-
assert.equal(sentryData[0].exception.values[0].stacktrace, undefined);
702702
assert.equal(sentryData[0].exception.values[0].mechanism.handled, false);
703703
assert.equal(sentryData[0].exception.values[0].mechanism.type, 'onunhandledrejection');
704704
done();
@@ -725,9 +725,9 @@ for (var idx in frames) {
725725
},
726726
function(sentryData) {
727727
if (debounceAssertEventCount(sentryData, 1, done)) {
728+
// non-error rejections doesnt provide stacktraces so we can skip the assertion
728729
assert.equal(sentryData[0].exception.values[0].value, '{"a":"b"}');
729730
assert.equal(sentryData[0].exception.values[0].type, 'UnhandledRejection');
730-
assert.equal(sentryData[0].exception.values[0].stacktrace, undefined);
731731
assert.equal(sentryData[0].exception.values[0].mechanism.handled, false);
732732
assert.equal(sentryData[0].exception.values[0].mechanism.type, 'onunhandledrejection');
733733
done();
@@ -761,9 +761,9 @@ for (var idx in frames) {
761761
},
762762
function(sentryData) {
763763
if (debounceAssertEventCount(sentryData, 1, done)) {
764-
assert.isAtMost(sentryData[0].exception.values[0].value.length, 303);
764+
// non-error rejections doesnt provide stacktraces so we can skip the assertion
765+
assert.equal(sentryData[0].exception.values[0].value.length, 253);
765766
assert.equal(sentryData[0].exception.values[0].type, 'UnhandledRejection');
766-
assert.equal(sentryData[0].exception.values[0].stacktrace, undefined);
767767
assert.equal(sentryData[0].exception.values[0].mechanism.handled, false);
768768
assert.equal(sentryData[0].exception.values[0].mechanism.type, 'onunhandledrejection');
769769
done();

packages/integrations/rollup.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function loadAllIntegrations() {
7676
file: `build/${file.replace('.ts', build.extension)}`,
7777
format: 'cjs',
7878
sourcemap: true,
79+
strict: false,
7980
},
8081
plugins: build.plugins,
8182
})),

packages/typescript/tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"alwaysStrict": false,
34
"declaration": true,
45
"declarationMap": true,
56
"downlevelIteration": true,
@@ -12,6 +13,7 @@
1213
"noFallthroughCasesInSwitch": true,
1314
"noImplicitAny": true,
1415
"noImplicitReturns": true,
16+
"noImplicitUseStrict": true,
1517
"noImplicitThis": true,
1618
"noUnusedLocals": true,
1719
"noUnusedParameters": true,

0 commit comments

Comments
 (0)