Skip to content

Commit

Permalink
feat: support custom schema on Electron (#3204)
Browse files Browse the repository at this point in the history
  • Loading branch information
seravifer authored Dec 20, 2024
1 parent 724b20b commit 3baa5e8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export const CHROME_XX_WEBPACK = {
at TESTTESTTEST.proxiedMethod(webpack:///./~/react-proxy/modules/createPrototypeProxy.js?:44:30)`,
}

export const ELECTRON = {
message: 'Default error',
name: 'Error',
stack: `Error: Default error
at dumpExceptionError (electron://-/file.js:41:27)
at HTMLButtonElement.onclick (electron://-/file.js:107:146)
at I.e.fn.(anonymous function) [as index] (electron://-/file.js:10:3651)`,
}

export const FIREFOX_3 = {
fileName: 'http://127.0.0.1:8000/js/stacktrace.js',
lineNumber: 44,
Expand Down
27 changes: 27 additions & 0 deletions packages/core/src/tools/stackTrace/computeStackTrace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,33 @@ Error: foo
})
})

it('should parse Electron schema with Chrome error', () => {
const stackFrames = computeStackTrace(CapturedExceptions.ELECTRON)

expect(stackFrames.stack.length).toEqual(3)
expect(stackFrames.stack[0]).toEqual({
args: [],
column: 27,
func: 'dumpExceptionError',
line: 41,
url: 'electron://-/file.js',
})
expect(stackFrames.stack[1]).toEqual({
args: [],
column: 146,
func: 'HTMLButtonElement.onclick',
line: 107,
url: 'electron://-/file.js',
})
expect(stackFrames.stack[2]).toEqual({
args: [],
column: 3651,
func: 'I.e.fn.(anonymous function) [as index]',
line: 10,
url: 'electron://-/file.js',
})
})

it('should parse nested eval() from Chrome', () => {
const stackFrames = computeStackTrace(CapturedExceptions.CHROME_48_EVAL)

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/tools/stackTrace/computeStackTrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export function computeStackTrace(ex: unknown): StackTrace {
stack,
}
}
const fileUrl = '((?:file|https?|blob|chrome-extension|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)'
const fileUrl =
'((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)'
const filePosition = '(?::(\\d+))'
const CHROME_LINE_RE = new RegExp(`^\\s*at (.*?) ?\\(${fileUrl}${filePosition}?${filePosition}?\\)?\\s*$`, 'i')

Expand Down

0 comments on commit 3baa5e8

Please sign in to comment.