Skip to content

fix(files): answer 499 instead of 500 when a client disconnects mid-serve - #9143

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/files-serve-client-abort
Oct 16, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/files-serve-client-abort

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • File serve route caught every error itself, so a client disconnect mid-read (navigating away, closing a preview) was logged at error and answered 500 — inflating 5xx counts with failures nobody saw
  • Rethrow when request.signal has aborted so withRouteHandler classifies it as a 499 at info, same as every other route (and the existing pattern in the Shopify OAuth callback)
  • Same guard in the cloud and local read helpers, which logged at error before rethrowing

Type of Change

  • Bug fix

Testing

  • New route test: a read that throws after the client aborts answers 499 with no error log. Verified red on the old code (500) and red with only the outer guard (helper still logs at error)
  • app/api/files/serve/[...path]/route.test.ts (13/13), biome, check:test-patterns, check:comment-hygiene; full suite/type-check/audits in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

…erve

The file serve route catches its own errors, so an abort thrown after the
client went away was logged at error and answered 500, bypassing the 499
classification withRouteHandler already applies. Rethrow when the request
signal has aborted, in the outer catch and in the cloud and local read
helpers that log before rethrowing.
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 16, 2026 10:04pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/app/api/files/serve/[...path]/route.ts
@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

File-serving errors now reach the shared 499 response when the client has disconnected.

  • Aborted file reads return 499 without file-error logs.

Reviews (1) · Last reviewed commit: "fix(files): answer 499 instead of 500 wh..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 854dc6a into staging Oct 16, 2026
98 of 100 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/files-serve-client-abort branch October 16, 2026 22:35

This branch was previously deployed

1 inactive deployment
Preview — 6975ce23 Deployed Oct 16, 2026 by vercel[bot]
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