-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): Set
:
as a part of gecko protocol regex group. (#4153)
Fixes: #4138 The original issue about `file` keyword also happens for everything in that group, such as `http`, `blob` and so on. And the problem originates from : `.*` between that group and `:`. It seems that `:` follows those keywords without anything in between, as far as I have seen from the tests. Removing that from the regex solved the issue without breaking any tests other than `safari-extension` and `safari-web-extension`, which are special-cased in https://github.com/getsentry/sentry-javascript/blob/d2e0cc4d683364dc500a681631b5be7df40ffec6/packages/browser/src/stack-parsers.ts#L160, and adding those two to the matching group also solved the issue of an extra `:` coming from https://github.com/getsentry/sentry-javascript/blob/d2e0cc4d683364dc500a681631b5be7df40ffec6/packages/browser/src/stack-parsers.ts#L165.
- Loading branch information
1 parent
57dee8e
commit cb925e3
Showing
11 changed files
with
373 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function httpsCall() { | ||
webpackDevServer(); | ||
} | ||
|
||
const webpackDevServer = () => { | ||
Response.httpCode(); | ||
}; | ||
|
||
class Response { | ||
constructor() {} | ||
|
||
static httpCode(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const decodeBlob = function() { | ||
(function readFile() { | ||
httpsCall(); | ||
})(); | ||
}; | ||
|
||
try { | ||
decodeBlob(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
65 changes: 65 additions & 0 deletions
65
packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'should parse function identifiers that contain protocol names correctly', | ||
async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
const frames = eventData.exception?.values?.[0].stacktrace?.frames; | ||
|
||
runInChromium(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'Function.httpCode' }, | ||
]); | ||
}); | ||
|
||
runInFirefox(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'httpCode' }, | ||
]); | ||
}); | ||
|
||
runInWebkit(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'decodeBlob' }, | ||
{ function: 'readFile' }, | ||
{ function: 'httpsCall' }, | ||
{ function: 'webpackDevServer' }, | ||
{ function: 'httpCode' }, | ||
]); | ||
}); | ||
}, | ||
); | ||
|
||
sentryTest( | ||
'should not add any part of the function identifier to beginning of filename', | ||
async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
// specifically, we're trying to avoid values like `Blob@file://path/to/file` in frames with function names like `makeBlob` | ||
Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}, | ||
); |
27 changes: 27 additions & 0 deletions
27
packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function https() { | ||
webpack(); | ||
} | ||
|
||
const webpack = () => { | ||
File.http(); | ||
}; | ||
|
||
class File { | ||
constructor() {} | ||
|
||
static http(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const blob = function() { | ||
(function file() { | ||
https(); | ||
})(); | ||
}; | ||
|
||
try { | ||
blob(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'should parse function identifiers that are protocol names correctly', | ||
async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
const frames = eventData.exception?.values?.[0].stacktrace?.frames; | ||
|
||
runInChromium(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'Function.http' }, | ||
]); | ||
}); | ||
|
||
runInFirefox(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'http' }, | ||
]); | ||
}); | ||
|
||
runInWebkit(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'blob' }, | ||
{ function: 'file' }, | ||
{ function: 'https' }, | ||
{ function: 'webpack' }, | ||
{ function: 'http' }, | ||
]); | ||
}); | ||
}, | ||
); | ||
|
||
sentryTest( | ||
'should not add any part of the function identifier to beginning of filename', | ||
async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}, | ||
); |
29 changes: 29 additions & 0 deletions
29
packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function foo() { | ||
bar(); | ||
} | ||
|
||
const bar = () => { | ||
Test.baz(); | ||
}; | ||
|
||
class Test { | ||
constructor() {} | ||
|
||
static baz(params) { | ||
throw new Error('test_err'); | ||
} | ||
} | ||
|
||
const qux = function() { | ||
(() => { | ||
(function() { | ||
foo(); | ||
})(); | ||
})(); | ||
}; | ||
|
||
try { | ||
qux(); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} |
68 changes: 68 additions & 0 deletions
68
packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; | ||
|
||
sentryTest( | ||
'should parse function identifiers correctly', | ||
async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
const frames = eventData.exception?.values?.[0].stacktrace?.frames; | ||
|
||
runInChromium(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'Function.baz' }, | ||
]); | ||
}); | ||
|
||
runInFirefox(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: 'qux/<' }, | ||
{ function: 'qux/</<' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'baz' }, | ||
]); | ||
}); | ||
|
||
runInWebkit(() => { | ||
expect(frames).toMatchObject([ | ||
{ function: 'global code' }, | ||
{ function: '?' }, | ||
{ function: 'qux' }, | ||
{ function: '?' }, | ||
{ function: '?' }, | ||
{ function: 'foo' }, | ||
{ function: 'bar' }, | ||
{ function: 'baz' }, | ||
]); | ||
}); | ||
}, | ||
); | ||
|
||
sentryTest( | ||
'should not add any part of the function identifier to beginning of filename', | ||
async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( | ||
// specifically, we're trying to avoid values like `Blob@file://path/to/file` in frames with function names like `makeBlob` | ||
Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), | ||
); | ||
}, | ||
); |
11 changes: 11 additions & 0 deletions
11
packages/integration-tests/suites/stacktraces/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
<script src="{{htmlWebpackPlugin.options.initialization}}"></script> | ||
</head> | ||
<body> | ||
<script src="{{htmlWebpackPlugin.options.subject}}"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.