Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 9a05738

Browse files
icedtoastkamilogorek
authored andcommitted
feat: Add support for custom schemes to Tracekit
Chromium Embedded Frameworks supports having custom schemes to load content. This would cause tracekit to not match those stacktraces, as the scheme was not in the fixed list that it searched for. To prevent mismatches, the cause for "any scheme" looks ahead to ensure that it is followed by a colon.
1 parent 3bada5d commit 9a05738

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

packages/browser/src/tracekit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ TraceKit._computeStackTrace = (function _computeStackTraceWrapper() {
477477
}
478478

479479
// Chromium based browsers: Chrome, Brave, new Opera, new Edge
480-
var chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|[a-z]:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
480+
var chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|[a-z]:|[-a-z]+(?=:)|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
481481
// gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
482482
// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
483483
// We need this specific case for now because we want no other regex to match.

packages/browser/test/unit/tracekit/original.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
SAFARI_7,
3939
SAFARI_8,
4040
SAFARI_8_EVAL,
41+
CHROMIUM_EMBEDDED_FRAMEWORK_CUSTOM_SCHEME
4142
} from './originalfixtures';
4243

4344
describe('Tracekit - Original Tests', () => {
@@ -1244,4 +1245,18 @@ describe('Tracekit - Original Tests', () => {
12441245
context: null,
12451246
});
12461247
});
1248+
1249+
it('should parse Chromium Embedded Framework errors with custom schemes', () => {
1250+
const stackFrames = _computeStackTrace(CHROMIUM_EMBEDDED_FRAMEWORK_CUSTOM_SCHEME);
1251+
expect(stackFrames).to.be.ok;
1252+
expect(stackFrames.stack.length).to.equal(1);
1253+
expect(stackFrames.stack[0]).to.deep.equal({
1254+
url: 'examplescheme://examplehost/cd351f7250857e22ceaa.worker.js',
1255+
func: '?',
1256+
args: [],
1257+
line: 70179,
1258+
column: 15,
1259+
context: null,
1260+
});
1261+
})
12471262
});

packages/browser/test/unit/tracekit/originalfixtures.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,3 +482,11 @@ export const ANDROID_REACT_NATIVE_PROD = {
482482
'value@index.android.bundle:29:927\n' +
483483
'[native code]',
484484
};
485+
486+
export const CHROMIUM_EMBEDDED_FRAMEWORK_CUSTOM_SCHEME = {
487+
message: 'message string',
488+
name: 'Error',
489+
stack:
490+
'Error: message string\n' +
491+
' at examplescheme://examplehost/cd351f7250857e22ceaa.worker.js:70179:15'
492+
};

0 commit comments

Comments
 (0)