Skip to content

Commit 278df2a

Browse files
JPeer264claude
andcommitted
test(bun): Run all Node integration suites on Bun
The Bun package now selects every Node suite and excludes the ones that fail on Bun, grouped by cause: Node-only features, no `http.server` span because Bun does not publish `http.server.request.start`, no `fetch` instrumentation because Bun's `fetch` does not publish undici channels, no outgoing `node:http` instrumentation on Bun 1.3.14 (JS-3507), and no auto-instrumentation under `bun run` (JS-3508). Excluded files do not run, so the job stays fast. The list is based on Bun 1.3.14, the version CI pins. The suites that assert the SDK name use `EXPECTED_SDK_NAME`, so they also pass with `@sentry/bun`, and `bun-runtime-metrics` runs on Bun instead of Node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3a84d73 commit 278df2a

6 files changed

Lines changed: 210 additions & 58 deletions

File tree

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Node suites that do not run on Bun, relative to `node-integration-tests`. A single test that
2+
// fails on Bun is skipped with `test.skipIf` on `RUNTIME` in the Node suite, not listed here.
3+
4+
// Node-only features: ANR and native thread watchdogs, child processes, the AWS Lambda Node runtime.
5+
const NODE_ONLY = [
6+
'suites/anr/test.ts',
7+
'suites/aws-serverless/**',
8+
'suites/breadcrumbs/**',
9+
'suites/child-process/test.ts',
10+
'suites/thread-blocked-native/test.ts',
11+
];
12+
13+
// Bun does not publish `http.server.request.start`, so `@sentry/node` creates no `http.server`
14+
// span and does not isolate incoming requests. `@sentry/bun` has `bunHttpServerIntegration` for this.
15+
const NO_HTTP_SERVER_SPANS = [
16+
'suites/sessions/**',
17+
'suites/tracing/envelope-header/sampleRate-propagation/test.ts',
18+
'suites/tracing/httpIntegration-streamed/test.ts',
19+
'suites/tracing/httpIntegration/test.ts',
20+
'suites/tracing/httpServerSpans-streamed-unrouted/test.ts',
21+
'suites/tracing/ignoreSpans-streamed/**',
22+
'suites/tracing/meta-tags-twp-errors/test.ts',
23+
'suites/tracing/meta-tags/test.ts',
24+
'suites/tracing/requestData-streamed/test.ts',
25+
'suites/tracing/sample-rand-propagation/test.ts',
26+
'suites/tracing/sample-rate-propagation/**',
27+
'suites/tracing/sampling-static/test.ts',
28+
'suites/tracing/sampling-streamed/test.ts',
29+
'suites/tracing/traceid-recycling-with-spans/test.ts',
30+
'suites/tracing/traceid-recycling/test.ts',
31+
];
32+
33+
// `@sentry/node` instruments `fetch` through undici's diagnostics channels, which Bun's `fetch`
34+
// does not publish. `@sentry/bun` has its own `fetchIntegration` for this.
35+
const NO_FETCH_INSTRUMENTATION = [
36+
'suites/tracing/double-baggage/**',
37+
'suites/tracing/http-client-span-streamed/test.ts',
38+
'suites/tracing/http-client-spans/fetch-basic-streamed/test.ts',
39+
'suites/tracing/http-client-spans/fetch-basic/test.ts',
40+
'suites/tracing/http-client-spans/fetch-error/test.ts',
41+
'suites/tracing/http-client-spans/fetch-forward-request-hook/test.ts',
42+
'suites/tracing/http-client-spans/fetch-headers-to-span-attributes/test.ts',
43+
'suites/tracing/http-client-spans/fetch-strip-query/test.ts',
44+
'suites/tracing/no-parent-span-client-report/test.ts',
45+
'suites/tracing/requests/fetch-breadcrumbs/test.ts',
46+
'suites/tracing/requests/fetch-no-trace-propagation/test.ts',
47+
'suites/tracing/requests/fetch-no-tracing-no-spans/test.ts',
48+
'suites/tracing/requests/fetch-no-tracing/test.ts',
49+
'suites/tracing/requests/fetch-sampled-no-active-span/test.ts',
50+
'suites/tracing/requests/fetch-unsampled/test.ts',
51+
'suites/tracing/requests/traceparent/test.ts',
52+
];
53+
54+
// JS-3507: Bun 1.3.14 (the CI version) does not instrument outgoing `node:http` requests. These
55+
// suites pass on Bun 1.4.2.
56+
const NO_OUTGOING_HTTP_INSTRUMENTATION = [
57+
'suites/tracing/dsc-txn-name-update/test.ts',
58+
'suites/tracing/http-client-spans/http-basic/test.ts',
59+
'suites/tracing/http-client-spans/http-strip-query/test.ts',
60+
'suites/tracing/requests/http-breadcrumbs/test.ts',
61+
'suites/tracing/requests/http-maxed-out-sockets/test.ts',
62+
'suites/tracing/requests/http-no-trace-propagation/test.ts',
63+
'suites/tracing/requests/http-no-tracing-no-spans/test.ts',
64+
'suites/tracing/requests/http-no-tracing/test.ts',
65+
'suites/tracing/requests/http-sampled-no-active-span/test.ts',
66+
'suites/tracing/requests/http-sampled/test.ts',
67+
'suites/tracing/requests/http-unsampled/test.ts',
68+
'suites/tracing/tracePropagationTargets/**',
69+
];
70+
71+
// JS-3508: `bun run` cannot inject the diagnostics channels into libraries, so framework,
72+
// database and AI instrumentation creates no spans. Apps must be built with `@sentry/bun/plugin`.
73+
const NO_AUTO_INSTRUMENTATION = [
74+
'suites/express/**',
75+
'suites/fs-instrumentation/test.ts',
76+
'suites/hono-sdk/test.ts',
77+
'suites/pino/test.ts',
78+
'suites/tracing/amqplib/test.ts',
79+
'suites/tracing/anthropic/test.ts',
80+
'suites/tracing/apollo-graphql/**',
81+
'suites/tracing/dataloader/test.ts',
82+
'suites/tracing/fastify/test.ts',
83+
'suites/tracing/genericPool-v2/test.ts',
84+
'suites/tracing/genericPool/test.ts',
85+
'suites/tracing/is-localhost/test.ts',
86+
'suites/tracing/google-genai-v2/test.ts',
87+
'suites/tracing/google-genai/test.ts',
88+
'suites/tracing/groq/test.ts',
89+
'suites/tracing/hapi/test.ts',
90+
'suites/tracing/ioredis-dc/test.ts',
91+
'suites/tracing/kafkajs/test.ts',
92+
'suites/tracing/knex/**',
93+
'suites/tracing/koa/test.ts',
94+
'suites/tracing/langchain/**',
95+
'suites/tracing/langgraph/test.ts',
96+
'suites/tracing/lru-memoizer/test.ts',
97+
'suites/tracing/mcp-handler-exact-once/test.ts',
98+
'suites/tracing/mcp-server-streamed/test.ts',
99+
'suites/tracing/mistral/test.ts',
100+
'suites/tracing/mongodb-v4/test.ts',
101+
'suites/tracing/mongodb-v5/test.ts',
102+
'suites/tracing/mongodb-v6/test.ts',
103+
'suites/tracing/mongodb-v7/test.ts',
104+
'suites/tracing/mongodb/test.ts',
105+
'suites/tracing/mongoose-tracing-channel/test.ts',
106+
'suites/tracing/mongoose-v5/test.ts',
107+
'suites/tracing/mongoose-v7/test.ts',
108+
'suites/tracing/mongoose-v8/test.ts',
109+
'suites/tracing/mongoose-v9/test.ts',
110+
'suites/tracing/mongoose/test.ts',
111+
'suites/tracing/mysql/test.ts',
112+
'suites/tracing/mysql2-tracing-channel/test.ts',
113+
'suites/tracing/mysql2/test.ts',
114+
'suites/tracing/openai/test.ts',
115+
'suites/tracing/openai/v6/test.ts',
116+
'suites/tracing/orchestrion-lazy-registration/test.ts',
117+
'suites/tracing/postgres-streamed/test.ts',
118+
'suites/tracing/postgres/test.ts',
119+
'suites/tracing/postgresjs-streamed/test.ts',
120+
'suites/tracing/postgresjs/test.ts',
121+
'suites/tracing/prisma-orm-v5/test.ts',
122+
'suites/tracing/prisma-orm-v6/test.ts',
123+
'suites/tracing/prisma-orm-v7/test.ts',
124+
'suites/tracing/redis-cache/test.ts',
125+
'suites/tracing/redis-dc/test.ts',
126+
'suites/tracing/redis/test.ts',
127+
'suites/tracing/tedious/test.ts',
128+
'suites/tracing/together-ai/test.ts',
129+
'suites/tracing/vercelai/**',
130+
];
131+
132+
// Fail on Bun, cause not investigated yet. `system-error` and `tracer-start-active-span-error`
133+
// fail on Bun 1.3.14 and pass on Bun 1.4.2. With the `@sentry/bun` alias, `system-error` also
134+
// fails because `@sentry/bun` does not include `nodeSystemErrorIntegration`.
135+
const NOT_TRIAGED = [
136+
'suites/contextLines/filename-with-spaces/test.ts',
137+
'suites/modules/test.ts',
138+
'suites/proxy/test.ts',
139+
'suites/system-error/test.ts',
140+
'suites/tracing/tracer-start-active-span-error/test.ts',
141+
];
142+
143+
export const NODE_SUITES_EXCLUDE = [
144+
'**/node_modules/**',
145+
...NODE_ONLY,
146+
...NO_HTTP_SERVER_SPANS,
147+
...NO_FETCH_INSTRUMENTATION,
148+
...NO_OUTGOING_HTTP_INSTRUMENTATION,
149+
...NO_AUTO_INSTRUMENTATION,
150+
...NOT_TRIAGED,
151+
];

dev-packages/bun-integration-tests/vite.config.mts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import { fileURLToPath } from 'node:url';
22
import { defineConfig } from 'vitest/config';
33
import baseConfig from '../../vite/vite.config';
4+
import { NODE_SUITES_EXCLUDE } from './node-suites/excludes';
45

56
const NODE_SUITES_ROOT = fileURLToPath(new URL('../node-integration-tests', import.meta.url));
67

7-
// Node suites that also run on Bun. The scenarios stay in `node-integration-tests`.
8-
const NODE_SUITES = [
9-
'suites/public-api/**/test.ts',
10-
'suites/client-reports/**/test.ts',
11-
'suites/featureFlags/**/test.ts',
12-
];
13-
14-
// Single tests that fail on Bun are skipped with `test.skipIf` on `RUNTIME` in the Node suite.
15-
const NODE_SUITES_EXCLUDE = ['**/node_modules/**'];
8+
// All Node suites also run on Bun. The scenarios stay in `node-integration-tests`.
9+
const NODE_SUITES = ['suites/**/test.ts'];
1610

1711
const nodeSuitesTest = {
1812
root: NODE_SUITES_ROOT,
@@ -73,6 +67,8 @@ export default defineConfig({
7367
...NODE_SUITES_EXCLUDE,
7468
// The scenario creates a `NodeClient` itself, which sends `sentry.javascript.node`.
7569
'suites/public-api/logs/test.ts',
70+
// `@sentry/bun` has `bunRuntimeMetricsIntegration` instead of `nodeRuntimeMetricsIntegration`.
71+
'suites/node-runtime-metrics/test.ts',
7672
],
7773
env: {
7874
RUNTIME: 'bun',

dev-packages/node-integration-tests/suites/bun-runtime-metrics/test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { afterAll, describe, expect, test } from 'vitest';
22
import { cleanupChildProcesses, createRunner } from '../../utils/runner';
3+
import { EXPECTED_SDK_NAME, RUNTIME } from '../../utils';
34

45
const SENTRY_ATTRIBUTES = {
56
'sentry.release': { value: '1.0.0', type: 'string' },
67
'sentry.environment': { value: 'test', type: 'string' },
7-
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
8+
'sentry.sdk.name': { value: EXPECTED_SDK_NAME, type: 'string' },
89
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
910
'sentry.origin': { value: 'auto.bun.runtime_metrics', type: 'string' },
1011
};
@@ -29,7 +30,8 @@ const counter = (name: string, unit?: string) => ({
2930
attributes: expect.objectContaining(SENTRY_ATTRIBUTES),
3031
});
3132

32-
describe('bunRuntimeMetricsIntegration', () => {
33+
// The integration measures the Bun process, so the suite runs on Bun only.
34+
describe.skipIf(RUNTIME !== 'bun')('bunRuntimeMetricsIntegration', () => {
3335
afterAll(() => {
3436
cleanupChildProcesses();
3537
});

0 commit comments

Comments
 (0)