Skip to content

Conversation

JealousGx
Copy link

@JealousGx JealousGx commented Oct 2, 2025

Change the session status from 'crashed' to 'unhandled' in the session update logic and tests. Extend the SessionStatus type to include 'unhandled' for better error handling.

Resolves #17842

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Comment on lines 30 to 36

export type SessionContext = Partial<Session>;

export type SessionStatus = 'ok' | 'exited' | 'crashed' | 'abnormal';
export type SessionStatus = 'ok' | 'exited' | 'crashed' | 'abnormal' | 'unhandled';

/** JSDoc */
export interface SessionAggregates {
Copy link

Choose a reason for hiding this comment

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

Potential bug: The new 'unhandled' session status is not handled by all parts of the system, leading to data corruption in session aggregation and inconsistent status reporting.
  • Description: The introduction of the 'unhandled' session status is incomplete. The session aggregation logic in packages/node-core/src/integrations/http/httpServerIntegration.ts contains a hardcoded mapping of statuses that was not updated to include 'unhandled'. When a session with this new status is processed, the logic attempts to access a non-existent key, which results in bucket['undefined'] = NaN. This corrupts the session aggregate data used for health monitoring. Additionally, packages/core/src/server-runtime-client.ts was not updated and still sets the session status to 'crashed' for unhandled exceptions, creating an inconsistency with other parts of the client that now use 'unhandled'.

  • Suggested fix: Update the session aggregation mapping in httpServerIntegration.ts to include the 'unhandled' status. Also, update server-runtime-client.ts and any other remaining locations, including tests, to use the 'unhandled' status instead of 'crashed' for consistency.
    severity: 0.75, confidence: 0.98

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

Copy link
Author

@JealousGx JealousGx Oct 2, 2025

Choose a reason for hiding this comment

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

@Lms24 , we dont need to update the test cases in httpServerIntegration.test.ts file right? I noticed crashed represents unhandled cases, so, it would be pointless to handle unhandled separately, if I got that right.

@Lms24 Lms24 self-assigned this Oct 2, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

} else {
// If it's an unhandled exception, we always set the status to 'unhandled'.
// 'unhandled' is the most severe status.
requestSession.status = 'unhandled';
Copy link

Choose a reason for hiding this comment

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

Bug: Session Status Update Logic Changed

The new logic for handled exceptions only updates session status from 'ok' to 'errored', changing previous behavior where 'abnormal' sessions would also transition. Additionally, unhandled exceptions now set the status to 'unhandled', making the existing comment referencing 'crashed' inaccurate.

Fix in Cursor Fix in Web

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Hey @JealousGx thanks a lot for opening this PR!

Unfortunately, we just identified that this task is a breaking change. Not specifically API breaking but it would break a lot of the Sentry product behaviour (see #17842 (comment)).

This means that we'll not merge this PR until we release the next major version of the SDK (no timeline yet). I still had a brief look over it and my main concern is that this PR changes the session status on server. I would like to revisit the logic here once we more specifically figured out if server-side session statuses. If I had known this upfront, I wouldn't have added the "Good first issue" label. Sorry for the confusion!

Since the next major version is still a while out, I'm gonna close this PR in the meantime. It is linked to the issue though so we can re-open and pick it up once we get to work on this. Also we'll make sure to give you proper credit!

Thanks for contributing and apologies for the confusion!

@Lms24 Lms24 closed this Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assign status unhandled instead of crashed to sessions in browser SDK

2 participants