fix(code.gs): wrap _doSingle normal-relay fetch in try/catch#1049
Open
dazzling-no-more wants to merge 1 commit into
Open
fix(code.gs): wrap _doSingle normal-relay fetch in try/catch#1049dazzling-no-more wants to merge 1 commit into
dazzling-no-more wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1047.
When
_doSinglefalls through to the normal relay path (cache disabled, or cache miss on a non-cachable request), theUrlFetchApp.fetch→getContent→base64Encodechain ran with no error wrapper. Any throw — most commonly when the response body approaches Apps Script's ~50 MB ceiling andbase64Encodeblows the V8 heap, but also URL-too-long, payload-too-large, quota exhaustion, or the 6-minute execution timeout — propagated unhandled, and Apps Script served its default<title>Web App</title>HTML error page in place of our JSON envelope.The Rust client (
parse_relay_jsoninsrc/domain_fronter.rs) then failed to find any JSON in the response and surfaced the crypticbad response: no json in: <!DOCTYPE html>...error, giving the user no signal as to the actual cause.The reporter's symptom — a single failing host (
shc-dist.lostsig.co, sonichacking.org) serving large ROM-hack binaries — matches this exactly: every other download worked because they were all comfortably under the body-size ceiling.Fix
Wrap the normal-relay block in
_doSinglewithtry { ... } catch (err) { return _json({ e: "fetch failed: " + String(err) }); }. This mirrors the per-item try/catch already present in_doBatch, and turns the silent HTML crash into a structuredFronterError::Relay("fetch failed: …")on the client side that pinpoints the real underlying error.The cache path is intentionally untouched:
_fetchAndCachealready wraps its own fetch in try/catch and returnsnullon any failure (so_doSinglefalls through cleanly to the normal relay).CACHE_MAX_BODY_BYTES(35 KB) so it cannot trip the size limits that caused this bug.Scope
assets/apps_script/Code.gs, +21 / −7.{ e: "..." }envelope is the same shape the Rust client already handles viaFronterError::Relay.Deployment note
Apps Script changes only take effect on deployments that re-paste the updated
Code.gs. Users on existing deployments will continue to see the old HTML crash until their deployment is refreshed — there is no client-side change here to ship.