Repository navigation
fix(edge): drain refused request bodies so the refusal reaches the client - #118
Conversation
…ient The hosted Edge runtime holds a function's response until the request body has been read. After #116, an oversized share or import request got its 413 only when the gateway gave up about 150 s later, and the same held for a rejected token sent with a large body. readBoundedBody now reads an oversized request to the end and discards it, for at most 10 s, before refusing it. Upstream responses are still cancelled. share and import-source drain the body the same way when they reject a token. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe shared bounded-body helper now drains oversized request bodies and can discard unused request bodies with a time limit and optional abort signal. The import-source and share handlers call it after authentication errors. Tests cover request draining and response cancellation. ChangesRequest Body Draining
Estimated code review effort: 3 (Moderate) | ~20 minutes
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing. Comment |
|
Codex review (gpt-6.1-sol, high) of c01815b: no findings. It noted that the wrong-method, banned-user and import-quota rejections still answer before reading the body. Those predate this PR, and real clients send small bodies there, so they stay as they are. |
Follow-up to #116, found while verifying it on staging before the production deploy.
Problem
The hosted Edge runtime doesn't send a function's response until the request body has been read. #116 made
shareandimport-sourcerefuse oversized requests before reading them, so on staging a 600 KB share got its 413 only when the gateway gave up, after about 150 s (a 503). A rejected token sent with a large body had the same problem. This didn't show locally under plain Deno.Fix
readBoundedBodyreads an oversized request to the end, discards it (spending at most 10 s), and then refuses it. Oversized upstream responses are still cancelled, not read.shareandimport-sourcedrain the body the same way whenrequireUserrejects the token.Verification
mainand passes here. The existing test that cancels an oversized upstream response still passes.npm run test:edge335/335, lint and typecheck pass. GitHub Actions is still refused for billing, so there is no CI run.supabase functions deploy --project-ref brifeyypjauyusmkptkx):shareand 0.4 s fromimport-source; before, it got no answer within 30 s.main'sshareback. That's expected, and this PR makes the two match.198.18.0.1and224.0.0.1got a 400. A real Wikipedia import worked. A normal share got a 30-day expiry and reads back anonymously.expiresInDays: 91got a 400.🤖 Generated with Claude Code
Summary by CodeRabbit