-
-
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.
fix(core): unref timer to not block node exit (#11430)
Add `unref` to make sure that the session flusher or metrics aggregator does not block nodejs exit. Especially important for serverless scenarios.
- Loading branch information
1 parent
9bfadb5
commit 5ab3631
Showing
6 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
dev-packages/node-integration-tests/suites/metrics/should-exit-forced.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,19 @@ | ||
const Sentry = require('@sentry/node'); | ||
|
||
function configureSentry() { | ||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
autoSessionTracking: false, | ||
}); | ||
|
||
Sentry.metrics.increment('test'); | ||
} | ||
|
||
async function main() { | ||
configureSentry(); | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
process.exit(0); | ||
} | ||
|
||
main(); |
18 changes: 18 additions & 0 deletions
18
dev-packages/node-integration-tests/suites/metrics/should-exit.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,18 @@ | ||
const Sentry = require('@sentry/node'); | ||
|
||
function configureSentry() { | ||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
autoSessionTracking: false, | ||
}); | ||
|
||
Sentry.metrics.increment('test'); | ||
} | ||
|
||
async function main() { | ||
configureSentry(); | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
} | ||
|
||
main(); |
21 changes: 21 additions & 0 deletions
21
dev-packages/node-integration-tests/suites/metrics/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,21 @@ | ||
import { createRunner } from '../../utils/runner'; | ||
|
||
describe('metrics', () => { | ||
test('should exit', done => { | ||
const runner = createRunner(__dirname, 'should-exit.js').start(); | ||
|
||
setTimeout(() => { | ||
expect(runner.childHasExited()).toBe(true); | ||
done(); | ||
}, 5_000); | ||
}); | ||
|
||
test('should exit forced', done => { | ||
const runner = createRunner(__dirname, 'should-exit-forced.js').start(); | ||
|
||
setTimeout(() => { | ||
expect(runner.childHasExited()).toBe(true); | ||
done(); | ||
}, 5_000); | ||
}); | ||
}); |
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