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
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export {
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
processSessionIntegration,
childProcessIntegration,
createSentryWinstonTransport,
redisIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/aws-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export {
pinoIntegration,
postgresIntegration,
postgresJsIntegration,
processSessionIntegration,
prismaIntegration,
childProcessIntegration,
createSentryWinstonTransport,
Expand Down
1 change: 1 addition & 0 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export {
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
processSessionIntegration,
hapiIntegration,
setupHapiErrorHandler,
honoIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
nodeContextIntegration,
onUncaughtExceptionIntegration,
onUnhandledRejectionIntegration,
processSessionIntegration,
} from '@sentry/node';
import { bunServerIntegration } from './integrations/bunserver';
import { makeFetchTransport } from './transports';
Expand Down Expand Up @@ -47,6 +48,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
contextLinesIntegration(),
nodeContextIntegration(),
modulesIntegration(),
processSessionIntegration(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing tests for new Bun integration feature

Low Severity · Bugbot Rules

This is a feat PR that adds processSessionIntegration to Bun's default integrations, but doesn't include any integration or E2E tests. Per the review rules file, feat PRs are expected to include at least one integration or E2E test. The existing test file packages/bun/test/init.test.ts tests integration setup patterns and could be extended to verify ProcessSession is included in the default integrations when initializing the Bun SDK.

Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The processSessionIntegration is added to Bun's default integrations but will not work with Bun.serve() because the beforeExit event it relies on never fires.
Severity: HIGH

Suggested Fix

Conditionally exclude processSessionIntegration from the default integrations when the SDK is used in a Bun environment, or implement an alternative mechanism to end sessions that is compatible with Bun's lifecycle, such as using the bunServerIntegration to hook into the server's shutdown process.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/bun/src/sdk.ts#L51

Potential issue: The `processSessionIntegration` is being added to the default
integrations for the Bun SDK. This integration relies on the Node.js
`process.on('beforeExit')` event to correctly terminate sessions. However, in Bun
environments using `Bun.serve()`, the `beforeExit` event is never fired. As a result,
for any Bun application utilizing the standard web server, Sentry sessions will not be
properly closed, leading to inaccurate session health and release health metrics. The
integration lacks a fallback mechanism for environments where `beforeExit` is not
supported.

Did we get this right? 👍 / 👎 to inform future reviews.

// Bun Specific
bunServerIntegration(),
...(hasSpansEnabled(_options) ? getAutoPerformanceIntegrations() : []),
Expand Down
6 changes: 3 additions & 3 deletions packages/bun/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ describe('Bun SDK', () => {

await new Promise(resolve => setTimeout(resolve, 1000));

expect(envelopes.length).toBe(1);
const errorEnvelope = envelopes.find(envelope => envelope?.[1][0]?.[0]?.type === 'event');
expect(errorEnvelope).toBeDefined();

const envelope = envelopes[0];
const event = envelope?.[1][0][1] as Event;
const event = errorEnvelope?.[1][0][1] as Event;

expect(event.sdk?.name).toBe('sentry.javascript.bun');

Expand Down
1 change: 1 addition & 0 deletions packages/google-cloud-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export {
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
processSessionIntegration,
hapiIntegration,
setupHapiErrorHandler,
honoIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/node-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { anrIntegration, disableAnrDetectionForCallback } from './integrations/a
export { spotlightIntegration } from './integrations/spotlight';
export { systemErrorIntegration } from './integrations/systemError';
export { childProcessIntegration } from './integrations/childProcess';
export { processSessionIntegration } from './integrations/processSession';
export { createSentryWinstonTransport } from './integrations/winston';
export { pinoIntegration } from './integrations/pino';

Expand Down
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export {
disableAnrDetectionForCallback,
spotlightIntegration,
childProcessIntegration,
processSessionIntegration,
pinoIntegration,
createSentryWinstonTransport,
SentryContextManager,
Expand Down
Loading