Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ jobs:
fail-fast: false
matrix:
# 1.3.14 is the oldest supported Bun version. Canary runs the `bun run` instrumentation
# suites (`node-suites-bun-run`), which need Bun 1.4.5 or later.
# suites (`node-suites-bun-run`), which need Bun 1.4.6 or later.
Comment thread
sentry-junior[bot] marked this conversation as resolved.
Resolved
bun: ['1.3.14', '1.4', 'canary']
shard: [1, 2, 3, 4]
steps:
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/bun-integration-tests/node-suites/excludes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const NO_FETCH_INSTRUMENTATION = [
'suites/tracing/requests/traceparent/test.ts',
];

// Before Bun 1.4.5, `bun run` cannot inject the diagnostics channels into libraries, so framework,
// Before Bun 1.4.6, `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`.
// The `node-suites-bun-build` and `node-suites-bun-run` projects run these suites.
// See https://github.com/getsentry/sentry-javascript/issues/23882
Expand Down Expand Up @@ -280,7 +280,7 @@ export const BUN_BUILD_EXCLUDE = [
];

// The `bun run` project (`node-suites-bun-run`) runs the suites of `NO_AUTO_INSTRUMENTATION` with
// `@sentry/bun/import` preloaded, on Bun 1.4.5 or later. These do not run there.
// `@sentry/bun/import` preloaded, on Bun 1.4.6 or later. These do not run there.

// The scenarios pass the incoming-request options (`maxRequestBodySize`, `ignoreIncomingRequestBody`)
// to `httpIntegration`. With `@sentry/bun`, `bunHttpServerIntegration` creates the `http.server` spans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import * as Sentry from '@sentry/bun';
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1.0,
// Bun 1.4.5 and later inject the channels in `bun run`, unless this is `false`.
// Bun 1.4.6 and later inject the channels in `bun run`, unless this is `false`.
enableRuntimeChannelInjection: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('no channel injection (Bun)', () => {
expect(output).toContain('@sentry/bun/plugin');
});

it.runIf(supports({ bunMin: '1.4.5' }))('does not warn when `init()` injects the channels in `bun run`', () => {
it.runIf(supports({ bunMin: '1.4.6' }))('does not warn when `init()` injects the channels in `bun run`', () => {
expect(runScenario('scenario-runtime-injection.ts')).not.toContain('No diagnostics-channel injection detected');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function runBun(args: string[]): { stdout: string; stderr: string; status: numbe
}

describe('orchestrion mysql instrumentation (Bun)', () => {
// Before Bun 1.4.5, a CommonJS module like `mysql` loses its named exports
// Before Bun 1.4.6, a CommonJS module like `mysql` loses its named exports
// when a runtime `onLoad` plugin returns it, so `bun run` cannot load it.
it.runIf(supports({ bunMin: '1.4.5' }))(
it.runIf(supports({ bunMin: '1.4.6' }))(
'fires the mysql channel in `bun run` with the `@sentry/bun/import` preload',
() => {
const run = runBun(['--preload', '@sentry/bun/import', join(dir, 'scenario.ts')]);
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/bun-integration-tests/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const NODE_SUITES_ROOT = fileURLToPath(new URL('../node-integration-tests', impo
// All Node suites also run on Bun. The scenarios stay in `node-integration-tests`.
const NODE_SUITES = ['suites/**/test.ts'];

// Before Bun 1.4.5, `bun run` cannot load the modules that the instrumentation transforms.
// Before Bun 1.4.6, `bun run` cannot load the modules that the instrumentation transforms.
const [bunMajor = 0, bunMinor = 0, bunPatch = 0] = execFileSync('bun', ['--version'], { encoding: 'utf8' })
.trim()
.split(/[.-]/)
.map(Number);
const BUN_RUN_INSTRUMENTS = bunMajor > 1 || (bunMajor === 1 && (bunMinor > 4 || (bunMinor === 4 && bunPatch >= 5)));
const BUN_RUN_INSTRUMENTS = bunMajor > 1 || (bunMajor === 1 && (bunMinor > 4 || (bunMinor === 4 && bunPatch >= 6)));

const AUTO_INSTRUMENTATION_SUITES = NO_AUTO_INSTRUMENTATION.map(glob =>
glob.endsWith('/**') ? `${glob}/test.ts` : glob,
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ is the reference setup.
itself does not get these files, so run a variant with `pnpm run test:run <app> --variant <runtime>`.
- **Bun and Deno versions**: a variant can pin the Bun or Deno version, for example `"bun-version": "1.4.4"` or
`"deno-version": "v2.9.0"`.
- **Bun**: under `bun run` before Bun 1.4.5 the SDK cannot inject diagnostics channels into packages that stay outside
- **Bun**: under `bun run` before Bun 1.4.6 the SDK cannot inject diagnostics channels into packages that stay outside
the build (for example Express behind `react-router-serve`), so those produce no spans on Bun. Where a test depends on them, branch
on `RUNTIME` and say why in a comment. An app that starts its own server can instead bundle it with
`@sentry/bun/plugin`, as `nestjs-12/bun-build.mjs` does. Bun 1.3 renames classes in bundles (`class Foo2`), which
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/src/import.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Orchestrion runtime hook for Bun 1.4.5 and later.
* Orchestrion runtime hook for Bun 1.4.6 and later.
*
* `init()` registers the same hook, but it only applies to modules imported
* after `init()`. Load this via the `--preload` argument to `bun run`, or the
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* });
* ```
*
* For `bun run` on Bun 1.4.5 or later, preload `@sentry/bun/import` instead.
* For `bun run` on Bun 1.4.6 or later, preload `@sentry/bun/import` instead.
*
* @module
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ declare const __SENTRY_CHANNEL_INJECTION__: boolean | undefined;
/**
* The tracing integrations for bun, added whenever spans are enabled. Most of them listen on
* the orchestrion diagnostics channels, which only exist when the app is built with
* `@sentry/bun/plugin`, or runs in `bun run` on Bun 1.4.5 or later. Otherwise, those
* `@sentry/bun/plugin`, or runs in `bun run` on Bun 1.4.6 or later. Otherwise, those
* integrations stay installed but create no spans.
*/
function getPerformanceIntegrations(options: Options): Integration[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface BaseBunOptions extends ServerRuntimeOptions {
/**
* Controls whether the SDK instruments supported modules (e.g. Express) when they load in
* `bun run`, so they emit the diagnostics channels that the channel-based integrations
* subscribe to. Needs Bun 1.4.5 or later.
* subscribe to. Needs Bun 1.4.6 or later.
*
* Set this to `false` to opt out, for example when you build your app with `@sentry/bun/plugin`.
*
Expand Down
6 changes: 3 additions & 3 deletions packages/server-runtime-injection/src/bun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ interface BunRuntime {
const PACKAGE_FILE_REGEXP = /^(.*[/\\]node_modules[/\\]((?:@[^/\\]+[/\\])?[^/\\]+))[/\\](.+)$/;

/**
* Before Bun 1.4.5, a CommonJS module returned by a runtime `onLoad` plugin loses its named
* Before Bun 1.4.6, a CommonJS module returned by a runtime `onLoad` plugin loses its named
* exports, so the transformed modules fail to load. See https://github.com/oven-sh/bun/issues/19279
*/
function hasBunRuntimePlugins(bunVersion: string): boolean {
const { major = 0, minor = 0, patch = 0 } = parseSemver(bunVersion);
return major > 1 || (major === 1 && (minor > 4 || (minor === 4 && patch >= 5)));
return major > 1 || (major === 1 && (minor > 4 || (minor === 4 && patch >= 6)));
}

/**
Expand All @@ -37,7 +37,7 @@ function hasBunRuntimePlugins(bunVersion: string): boolean {
*
* `@sentry/bun` calls this in `init()`, where it only reaches modules imported after `init()`, and
* in its `@sentry/bun/import` preload, which also reaches the static imports of the entry module.
* It does nothing outside of Bun, before Bun 1.4.5, and after the first call.
* It does nothing outside of Bun, before Bun 1.4.6, and after the first call.
*/
export function registerBunRuntimeInjection(): void {
const marker = (GLOBAL_OBJ.__SENTRY_ORCHESTRION__ ??= {});
Expand Down
10 changes: 5 additions & 5 deletions packages/server-runtime-injection/test/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ describe('registerBunRuntimeInjection', () => {
});

it('transforms instrumented modules with `Bun.plugin()` and records them', () => {
vi.stubGlobal('Bun', { version: '1.4.5', plugin: pluginMock });
vi.stubGlobal('Bun', { version: '1.4.6', plugin: pluginMock });

registerBunRuntimeInjection();
registerBunRuntimeInjection();
Expand All @@ -386,7 +386,7 @@ describe('registerBunRuntimeInjection', () => {
});

it('leaves files without a transform to Bun', () => {
vi.stubGlobal('Bun', { version: '1.4.5', plugin: pluginMock });
vi.stubGlobal('Bun', { version: '1.4.6', plugin: pluginMock });

registerBunRuntimeInjection();

Expand All @@ -403,7 +403,7 @@ describe('registerBunRuntimeInjection', () => {

it('marks runtime injection unavailable when `Bun.plugin()` throws', () => {
vi.stubGlobal('Bun', {
version: '1.4.5',
version: '1.4.6',
plugin: () => {
throw new Error('boom');
},
Expand All @@ -413,8 +413,8 @@ describe('registerBunRuntimeInjection', () => {
expect(GLOBAL_OBJ.__SENTRY_ORCHESTRION__).toEqual({ runtimeUnavailable: true });
});

it('registers nothing on Bun versions that lose CommonJS exports', () => {
vi.stubGlobal('Bun', { version: '1.4.4', plugin: pluginMock });
it.each(['1.4.4', '1.4.5'])('registers nothing on Bun %s, which loses CommonJS exports', version => {
vi.stubGlobal('Bun', { version, plugin: pluginMock });

registerBunRuntimeInjection();

Expand Down
2 changes: 1 addition & 1 deletion packages/server-utils/src/ai/flue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function warnIfPiAiNotInstrumented(): void {

function getPiAiInstrumentationHint(): string {
if (isBun()) {
return 'On Bun 1.4.5 or later, run your app with `bun --preload @sentry/bun/import app.ts`. Or build it with `sentryBunPlugin()` from `@sentry/bun/plugin`.';
return 'On Bun 1.4.6 or later, run your app with `bun --preload @sentry/bun/import app.ts`. Or build it with `sentryBunPlugin()` from `@sentry/bun/plugin`.';
}
if (isDeno()) {
return 'Run your app with `deno run --preload=npm:@sentry/deno/import app.ts`.';
Expand Down
2 changes: 1 addition & 1 deletion packages/server-utils/src/orchestrion/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function detectOrchestrionSetup(): void {
// oxlint-disable-next-line no-console
console.warn(
'[Sentry] No diagnostics-channel injection detected. Channel-based integrations will not record ' +
'spans or capture errors. On Bun 1.4.5 or later, run your app with `bun --preload @sentry/bun/import`. ' +
'spans or capture errors. On Bun 1.4.6 or later, run your app with `bun --preload @sentry/bun/import`. ' +
'Or build your app with `@sentry/bun/plugin`.',
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Flue warning about uninstrumented pi-ai', () => {
[
'Bun',
{ Bun: {} },
'On Bun 1.4.5 or later, run your app with `bun --preload @sentry/bun/import app.ts`. Or build it with `sentryBunPlugin()` from `@sentry/bun/plugin`.',
'On Bun 1.4.6 or later, run your app with `bun --preload @sentry/bun/import app.ts`. Or build it with `sentryBunPlugin()` from `@sentry/bun/plugin`.',
],
['Deno', { Deno: {} }, 'Run your app with `deno run --preload=npm:@sentry/deno/import app.ts`.'],
[
Expand Down
Loading