-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test(bun): Run all Node integration suites on Bun #24610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f4164db
8e147d6
7bca7eb
d72d702
1312564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,162 @@ | ||||||||
| // Node suites that do not run on Bun, relative to `node-integration-tests`. A single test that | ||||||||
| // fails on Bun is skipped with `test.skipIf` on `RUNTIME` in the Node suite, not listed here. | ||||||||
|
|
||||||||
| // Node-only features: ANR and native thread watchdogs, child processes, the AWS Lambda Node runtime, | ||||||||
| // and `node:sqlite`, which `flue` needs. | ||||||||
| const NODE_ONLY = [ | ||||||||
| 'suites/anr/test.ts', | ||||||||
| 'suites/aws-serverless/**', | ||||||||
| 'suites/breadcrumbs/**', | ||||||||
| 'suites/child-process/test.ts', | ||||||||
| 'suites/thread-blocked-native/test.ts', | ||||||||
| 'suites/tracing/flue/test.ts', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // Bun does not publish `http.server.request.start`, so `@sentry/node` creates no `http.server` | ||||||||
| // span and does not isolate incoming requests. `@sentry/bun` has `bunHttpServerIntegration` for this. | ||||||||
| const NO_HTTP_SERVER_SPANS = [ | ||||||||
| 'suites/sessions/**', | ||||||||
| 'suites/tracing/envelope-header/sampleRate-propagation/test.ts', | ||||||||
| 'suites/tracing/httpIntegration-streamed/test.ts', | ||||||||
| 'suites/tracing/httpIntegration/test.ts', | ||||||||
| 'suites/tracing/httpServerSpans-streamed-unrouted/test.ts', | ||||||||
| 'suites/tracing/ignoreSpans-streamed/**', | ||||||||
| 'suites/tracing/meta-tags-twp-errors/test.ts', | ||||||||
| 'suites/tracing/meta-tags/test.ts', | ||||||||
| 'suites/tracing/requestData-streamed/test.ts', | ||||||||
| 'suites/tracing/sample-rand-propagation/test.ts', | ||||||||
| 'suites/tracing/sample-rate-propagation/**', | ||||||||
| 'suites/tracing/sampling-static/test.ts', | ||||||||
| 'suites/tracing/sampling-streamed/test.ts', | ||||||||
| 'suites/tracing/traceid-recycling-with-spans/test.ts', | ||||||||
| 'suites/tracing/traceid-recycling/test.ts', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // `@sentry/node` instruments `fetch` through undici's diagnostics channels, which Bun's `fetch` | ||||||||
| // does not publish. `@sentry/bun` has its own `fetchIntegration` for this. | ||||||||
| const NO_FETCH_INSTRUMENTATION = [ | ||||||||
| 'suites/tracing/double-baggage/**', | ||||||||
| 'suites/tracing/http-client-span-streamed/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-basic-streamed/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-basic/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-error/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-forward-request-hook/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-headers-to-span-attributes/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/fetch-strip-query/test.ts', | ||||||||
| 'suites/tracing/no-parent-span-client-report/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-breadcrumbs/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-no-trace-propagation/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-no-tracing-no-spans/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-no-tracing/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-sampled-no-active-span/test.ts', | ||||||||
| 'suites/tracing/requests/fetch-unsampled/test.ts', | ||||||||
| 'suites/tracing/requests/traceparent/test.ts', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // Bun 1.3.14 (the CI version) does not instrument outgoing `node:http` requests. These suites pass | ||||||||
| // on Bun 1.4.2. See https://github.com/getsentry/sentry-javascript/issues/23881 | ||||||||
| const NO_OUTGOING_HTTP_INSTRUMENTATION = [ | ||||||||
| 'suites/tracing/dsc-txn-name-update/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/http-basic/test.ts', | ||||||||
| 'suites/tracing/http-client-spans/http-strip-query/test.ts', | ||||||||
| 'suites/tracing/requests/http-breadcrumbs/test.ts', | ||||||||
| 'suites/tracing/requests/http-maxed-out-sockets/test.ts', | ||||||||
| 'suites/tracing/requests/http-no-trace-propagation/test.ts', | ||||||||
| 'suites/tracing/requests/http-no-tracing-no-spans/test.ts', | ||||||||
| 'suites/tracing/requests/http-no-tracing/test.ts', | ||||||||
| 'suites/tracing/requests/http-sampled-no-active-span/test.ts', | ||||||||
| 'suites/tracing/requests/http-sampled/test.ts', | ||||||||
| 'suites/tracing/requests/http-unsampled/test.ts', | ||||||||
| 'suites/tracing/tracePropagationTargets/**', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // `bun run` cannot inject the diagnostics channels into libraries, so framework, database and AI | ||||||||
| // instrumentation creates no spans. Apps must be built with `@sentry/bun/plugin`. | ||||||||
| // See https://github.com/getsentry/sentry-javascript/issues/23882 | ||||||||
| const NO_AUTO_INSTRUMENTATION = [ | ||||||||
| 'suites/express/**', | ||||||||
| 'suites/fs-instrumentation/test.ts', | ||||||||
| 'suites/hono-sdk/test.ts', | ||||||||
| 'suites/pino/test.ts', | ||||||||
| 'suites/tracing/amqplib/test.ts', | ||||||||
| 'suites/tracing/anthropic/test.ts', | ||||||||
| 'suites/tracing/apollo-graphql/**', | ||||||||
| 'suites/tracing/dataloader/test.ts', | ||||||||
| 'suites/tracing/fastify/test.ts', | ||||||||
| 'suites/tracing/genericPool-v2/test.ts', | ||||||||
| 'suites/tracing/genericPool/test.ts', | ||||||||
| 'suites/tracing/is-localhost/test.ts', | ||||||||
| 'suites/tracing/google-genai-v2/test.ts', | ||||||||
| 'suites/tracing/google-genai/test.ts', | ||||||||
| 'suites/tracing/groq/test.ts', | ||||||||
| 'suites/tracing/hapi/test.ts', | ||||||||
| 'suites/tracing/ioredis-dc/test.ts', | ||||||||
| 'suites/tracing/kafkajs/test.ts', | ||||||||
| 'suites/tracing/knex/**', | ||||||||
| 'suites/tracing/koa/test.ts', | ||||||||
| 'suites/tracing/langchain/**', | ||||||||
| 'suites/tracing/langgraph/test.ts', | ||||||||
| 'suites/tracing/lru-memoizer/test.ts', | ||||||||
| 'suites/tracing/mastra/test.ts', | ||||||||
| 'suites/tracing/mcp-handler-exact-once/test.ts', | ||||||||
| 'suites/tracing/mcp-server-streamed/test.ts', | ||||||||
| 'suites/tracing/mistral/test.ts', | ||||||||
| 'suites/tracing/mongodb-v4/test.ts', | ||||||||
| 'suites/tracing/mongodb-v5/test.ts', | ||||||||
| 'suites/tracing/mongodb-v6/test.ts', | ||||||||
| 'suites/tracing/mongodb-v7/test.ts', | ||||||||
| 'suites/tracing/mongodb/test.ts', | ||||||||
| 'suites/tracing/mongoose-tracing-channel/test.ts', | ||||||||
| 'suites/tracing/mongoose-v5/test.ts', | ||||||||
| 'suites/tracing/mongoose-v7/test.ts', | ||||||||
| 'suites/tracing/mongoose-v8/test.ts', | ||||||||
| 'suites/tracing/mongoose-v9/test.ts', | ||||||||
| 'suites/tracing/mongoose/test.ts', | ||||||||
| 'suites/tracing/mysql/test.ts', | ||||||||
| 'suites/tracing/mysql2-tracing-channel/test.ts', | ||||||||
| 'suites/tracing/mysql2/test.ts', | ||||||||
| 'suites/tracing/openai/test.ts', | ||||||||
| 'suites/tracing/openai/v6/test.ts', | ||||||||
| 'suites/tracing/openai/v7/test.ts', | ||||||||
| 'suites/tracing/orchestrion-lazy-registration/test.ts', | ||||||||
| 'suites/tracing/postgres-streamed/test.ts', | ||||||||
| 'suites/tracing/postgres/test.ts', | ||||||||
| 'suites/tracing/postgresjs-streamed/test.ts', | ||||||||
| 'suites/tracing/postgresjs/test.ts', | ||||||||
| 'suites/tracing/prisma-orm-v5/test.ts', | ||||||||
| 'suites/tracing/prisma-orm-v6/test.ts', | ||||||||
| 'suites/tracing/prisma-orm-v7/test.ts', | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why the CI is failing, because a new test was added on develop, but not here. Obviously, once this lands, it'll be less of an issue. But, in addition to adding it to the set right now, I think we can help prevent the footgun that exposes. I'd recommend:
Suggested change
|
||||||||
| 'suites/tracing/redis-cache/test.ts', | ||||||||
| 'suites/tracing/redis-dc/test.ts', | ||||||||
| 'suites/tracing/redis/test.ts', | ||||||||
| 'suites/tracing/tedious/test.ts', | ||||||||
| 'suites/tracing/together-ai/test.ts', | ||||||||
| 'suites/tracing/vercelai/**', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // Fail on Bun, cause not investigated yet. `system-error` and `tracer-start-active-span-error` | ||||||||
| // fail on Bun 1.3.14 and pass on Bun 1.4.2. With the `@sentry/bun` alias, `system-error` also | ||||||||
| // fails because `@sentry/bun` does not include `nodeSystemErrorIntegration`. | ||||||||
| const NOT_TRIAGED = [ | ||||||||
| 'suites/contextLines/filename-with-spaces/test.ts', | ||||||||
| 'suites/modules/test.ts', | ||||||||
| 'suites/proxy/test.ts', | ||||||||
| 'suites/system-error/test.ts', | ||||||||
| 'suites/tracing/tracer-start-active-span-error/test.ts', | ||||||||
| ]; | ||||||||
|
|
||||||||
| // Bun garbage-collects a diagnostics channel that no code references, and its subscribers with it. | ||||||||
| // `graphql` 17 publishes its own tracing channels, so the integration only subscribes to them, and | ||||||||
| // no spans arrive. See https://github.com/oven-sh/bun/issues/43086 | ||||||||
| const CHANNEL_GARBAGE_COLLECTED = ['suites/tracing/graphql-tracing-channel/**']; | ||||||||
|
|
||||||||
| export const NODE_SUITES_EXCLUDE = [ | ||||||||
| '**/node_modules/**', | ||||||||
| ...NODE_ONLY, | ||||||||
| ...NO_HTTP_SERVER_SPANS, | ||||||||
| ...NO_FETCH_INSTRUMENTATION, | ||||||||
| ...NO_OUTGOING_HTTP_INSTRUMENTATION, | ||||||||
| ...NO_AUTO_INSTRUMENTATION, | ||||||||
| ...NOT_TRIAGED, | ||||||||
| ...CHANNEL_GARBAGE_COLLECTED, | ||||||||
| ]; | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import { afterAll, describe, expect, test } from 'vitest'; | ||
| import { cleanupChildProcesses, createRunner } from '../../utils/runner'; | ||
| import { EXPECTED_SDK_NAME, RUNTIME } from '../../utils'; | ||
|
|
||
| const SENTRY_ATTRIBUTES = { | ||
| 'sentry.release': { value: '1.0.0', type: 'string' }, | ||
| 'sentry.environment': { value: 'test', type: 'string' }, | ||
| 'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' }, | ||
| 'sentry.sdk.name': { value: EXPECTED_SDK_NAME, type: 'string' }, | ||
| 'sentry.sdk.version': { value: expect.any(String), type: 'string' }, | ||
| 'sentry.origin': { value: 'auto.bun.runtime_metrics', type: 'string' }, | ||
| }; | ||
|
|
@@ -29,7 +30,8 @@ const counter = (name: string, unit?: string) => ({ | |
| attributes: expect.objectContaining(SENTRY_ATTRIBUTES), | ||
| }); | ||
|
|
||
| describe('bunRuntimeMetricsIntegration', () => { | ||
| // The integration measures the Bun process, so the suite runs on Bun only. | ||
| describe.skipIf(RUNTIME !== 'bun')('bunRuntimeMetricsIntegration', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this test to dev-packages/bun-integration-tests, and then remove this |
||
| afterAll(() => { | ||
| cleanupChildProcesses(); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way this is structured right now, bun's fetchIntegration tests don't actually run.
It's a little complicated to explain in ye olde englishe, so I wrote up a patch that would bring the lost coverage. It's a little complicated, there might be an opportunity to simplify it down a bit, or if you think it's cleaner, we could do as a followup. But I think it's important to not lose test coverage in the end, if possible.
https://gist.github.com/isaacs/06a374f207bca343b51d9ad831485b7b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Same for http.server tests. Updated gist.)