-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
748 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,12 @@ const ANR_EVENT_WITH_SCOPE = { | |
user: { | ||
email: '[email protected]', | ||
}, | ||
breadcrumbs: [ | ||
breadcrumbs: expect.arrayContaining([ | ||
{ | ||
timestamp: expect.any(Number), | ||
message: 'important message!', | ||
}, | ||
], | ||
]), | ||
}; | ||
|
||
conditionalTest({ min: 16 })('should report ANR when event loop blocked', () => { | ||
|
27 changes: 27 additions & 0 deletions
27
dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/app.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,27 @@ | ||
import { spawn } from 'child_process'; | ||
import { join } from 'path'; | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
import { Worker } from 'worker_threads'; | ||
|
||
const __dirname = new URL('.', import.meta.url).pathname; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
transport: loggingTransport, | ||
}); | ||
|
||
await new Promise(resolve => { | ||
const child = spawn('sleep', ['a']); | ||
child.on('error', resolve); | ||
child.on('exit', resolve); | ||
}); | ||
|
||
await new Promise(resolve => { | ||
const worker = new Worker(join(__dirname, 'worker.mjs')); | ||
worker.on('error', resolve); | ||
worker.on('exit', resolve); | ||
}); | ||
|
||
throw new Error('This is a test error'); |
48 changes: 48 additions & 0 deletions
48
dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/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,48 @@ | ||
import type { Event } from '@sentry/types'; | ||
import { conditionalTest } from '../../../utils'; | ||
import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; | ||
|
||
const EVENT = { | ||
// and an exception that is our ANR | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'This is a test error', | ||
}, | ||
], | ||
}, | ||
breadcrumbs: [ | ||
{ | ||
timestamp: expect.any(Number), | ||
category: 'child_process', | ||
message: "Child process exited with code '1'", | ||
level: 'warning', | ||
data: { | ||
spawnfile: 'sleep', | ||
}, | ||
}, | ||
{ | ||
timestamp: expect.any(Number), | ||
category: 'worker_thread', | ||
message: "Worker thread errored with 'Worker error'", | ||
level: 'error', | ||
data: { | ||
threadId: expect.any(Number), | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
conditionalTest({ min: 20 })('should capture process and thread breadcrumbs', () => { | ||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('ESM', done => { | ||
createRunner(__dirname, 'app.mjs') | ||
.withMockSentryServer() | ||
.expect({ event: EVENT as Event }) | ||
.start(done); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/worker.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 @@ | ||
throw new Error('Worker error'); |
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
Oops, something went wrong.