Skip to content

fix(sandbox): add logging for session resets#446

Merged
dcramer merged 3 commits into
mainfrom
fix/sandbox-session-logging
May 29, 2026
Merged

fix(sandbox): add logging for session resets#446
dcramer merged 3 commits into
mainfrom
fix/sandbox-session-logging

Conversation

@sentry-junior
Copy link
Copy Markdown
Contributor

@sentry-junior sentry-junior Bot commented May 29, 2026

What

Three paths in session.ts that create a new sandbox session were completely silent, making it impossible to diagnose unexpected workspace resets from Sentry after the fact. This adds minimal structured log events to each.

Changes

  • sandbox_restore_hint_failed (warn) — Sandbox.get() threw when trying to resume by name; logs hint ID and error message. These aren't captured anywhere on the sandbox.get span.
  • sandbox_hint_discarded_profile_mismatch (info) — dependency profile hash changed between turns (deploy happened); event name only, profile hashes already on the active span via setSpanAttributes.
  • sandbox_unavailable_recreating (warn) — sandbox returned unavailable during a reachability probe; event name only, recovery source already on the active span via setSpanAttributes.

No behavioral change.

Verified

  • Typecheck passes (pnpm --filter @sentry/junior typecheck)
  • All CI checks pass

View Session in Sentry

Log when the sandbox hint is dropped (profile mismatch), when a
hinted sandbox cannot be restored (Sandbox.get failure), and when
an unavailable sandbox triggers recreation. All three paths were
previously silent, making it impossible to diagnose unexpected
session resets from Sentry after the fact.

Co-Authored-By: claude-sonnet-4-5 <noreply@anthropic.com>

Co-authored-by: David Cramer <david@sentry.io>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment May 29, 2026 7:43pm

Request Review

recovery.source and the profile hash attrs are set on the active
sandbox.acquire span via setSpanAttributes immediately above each
log call. No need to duplicate them in the log record.

Co-authored-by: David Cramer <david@sentry.io>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d4ca56b. Configure here.

Comment thread packages/junior/src/chat/sandbox/session.ts
Log records should carry the key attrs inline so they're debuggable
without jumping to the correlated span. Re-adds recovery.source to
sandbox_unavailable_recreating and the profile hashes to
sandbox_hint_discarded_profile_mismatch.
@dcramer dcramer merged commit dd4165a into main May 29, 2026
16 checks passed
@dcramer dcramer deleted the fix/sandbox-session-logging branch May 29, 2026 19:48
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.

1 participant