Commit fb23878
test(node): Auto-flush node-integration-tests via beforeExit (#20960)
Removes the `setInterval(() => {}, 1000)` boilerplate from 46
integration-test scenarios by injecting a `beforeExit` auto-flush hook
from the runner instead.
**Why the boilerplate existed.** Most scenarios end synchronously after
queuing spans/events. The OTel batch processor and Sentry client flush
asynchronously, so without a live handle Node exits before envelopes
reach the (logging) transport. Each scenario kept the loop alive with a
`setInterval`; the runner SIGTERMed the child once it had seen the
expected envelopes.
**What replaces it.** A small `auto-flush.{cjs,mjs}` loader injected via
`--require` / `--import` registers a `process.on('beforeExit', () =>
Sentry.flush(2000))`. When the loop drains, the awaited flush keeps it
alive until queued envelopes are sent, then the process exits naturally
— no setInterval, no SIGTERM handler interaction, no force-exit timer.
Two loader variants because Node's CJS and ESM module caches are
separate: ESM scenarios get `auto-flush.mjs` so `import * as Sentry`
resolves to the same SDK instance the scenario uses; CJS gets
`auto-flush.cjs`. The runner picks the right one based on whether
`flags` already contain `--import`.
Skipped when no envelopes are expected (e.g. ANR `should-exit`,
`ensureNoErrorOutput`) — those tests assert the child exits naturally
and auto-flush would delay them by retrying HTTP requests against the
fake DSN.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 11a20b6 commit fb23878
44 files changed
Lines changed: 74 additions & 124 deletions
File tree
- dev-packages/node-integration-tests
- suites/tracing
- amqplib
- apollo-graphql
- useOperationNameForRootSpan
- dataloader
- genericPool
- kafkajs
- knex
- mysql2
- pg
- lru-memoizer
- mongodb
- mongoose
- mysql2
- mysql
- postgresjs
- postgres
- prisma-orm-v5
- prisma-orm-v6
- prisma-orm-v7
- redis-cache
- redis-dc
- redis
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
0 commit comments