Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions dev-packages/bun-integration-tests/node-suites/excludes.ts
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 = [

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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.)

'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',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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:

  • Add a line in dev-packages/node-integration-tests/README.md, like "When adding a test to this suite, also consider whether that test can run properly on Bun. If not, create an exclusion in dev-packages/bun-integration-tests/node-suites/excludes.ts."
  • This could also maybe be added to our skills which mention node-integration-tests (maybe just tell them to be sure to check the readme?)
    • .claude/skills/add-ai-integration/SKILL.md
    • .claude/skills/vendor-otel/SKILL.md
    • .claude/skills/write-tests/SKILL.md
Suggested change
'suites/tracing/prisma-orm-v7/test.ts',
'suites/tracing/prisma-orm-v7/test.ts',
'suites/tracing/prisma-orm-v8/test.ts',

'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,
];
14 changes: 5 additions & 9 deletions dev-packages/bun-integration-tests/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
import baseConfig from '../../vite/vite.config';
import { NODE_SUITES_EXCLUDE } from './node-suites/excludes';

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

// Node suites that also run on Bun. The scenarios stay in `node-integration-tests`.
const NODE_SUITES = [
'suites/public-api/**/test.ts',
'suites/client-reports/**/test.ts',
'suites/featureFlags/**/test.ts',
];

// Single tests that fail on Bun are skipped with `test.skipIf` on `RUNTIME` in the Node suite.
const NODE_SUITES_EXCLUDE = ['**/node_modules/**'];
// All Node suites also run on Bun. The scenarios stay in `node-integration-tests`.
const NODE_SUITES = ['suites/**/test.ts'];
Comment thread
isaacs marked this conversation as resolved.

const nodeSuitesTest = {
root: NODE_SUITES_ROOT,
Expand Down Expand Up @@ -76,6 +70,8 @@ export default defineConfig({
...NODE_SUITES_EXCLUDE,
// The scenario creates a `NodeClient` itself, which sends `sentry.javascript.node`.
'suites/public-api/logs/test.ts',
// `@sentry/bun` has `bunRuntimeMetricsIntegration` instead of `nodeRuntimeMetricsIntegration`.
'suites/node-runtime-metrics/test.ts',
],
env: {
RUNTIME: 'bun',
Expand Down
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' },
};
Expand All @@ -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', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 skipIf condition?

afterAll(() => {
cleanupChildProcesses();
});
Expand Down
Loading
Loading