forked from getsentry/sentry-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Add scope to ANR events (getsentry#11256)
Closes getsentry#10668 Rather than inject large unchecked JavaScript strings to run via `Runtime.evaluate`, when the ANR integration is enabled, we add a function to `global.__SENTRY_GET_SCOPES__` which can then be called via the debugger when the event loop is suspended.
- Loading branch information
1 parent
9d5b60e
commit 3493d11
Showing
9 changed files
with
173 additions
and
18 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
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
53 changes: 53 additions & 0 deletions
53
dev-packages/node-integration-tests/suites/anr/isolated.mjs
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,53 @@ | ||
import * as assert from 'assert'; | ||
import * as crypto from 'crypto'; | ||
|
||
import * as Sentry from '@sentry/node'; | ||
|
||
setTimeout(() => { | ||
process.exit(); | ||
}, 10000); | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
debug: true, | ||
autoSessionTracking: false, | ||
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })], | ||
}); | ||
|
||
async function longWork() { | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
|
||
for (let i = 0; i < 20; i++) { | ||
const salt = crypto.randomBytes(128).toString('base64'); | ||
const hash = crypto.pbkdf2Sync('myPassword', salt, 10000, 512, 'sha512'); | ||
assert.ok(hash); | ||
} | ||
} | ||
|
||
function neverResolve() { | ||
return new Promise(() => { | ||
// | ||
}); | ||
} | ||
|
||
const fns = [ | ||
neverResolve, | ||
neverResolve, | ||
neverResolve, | ||
neverResolve, | ||
neverResolve, | ||
longWork, // [5] | ||
neverResolve, | ||
neverResolve, | ||
neverResolve, | ||
neverResolve, | ||
]; | ||
|
||
for (let id = 0; id < 10; id++) { | ||
Sentry.withIsolationScope(async () => { | ||
Sentry.setUser({ id }); | ||
|
||
await fns[id](); | ||
}); | ||
} |
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
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