Repository navigation
fix: normalize island CSS paths for Windows compatibility - #62
Merged
Brooooooklyn merged 1 commit intoApr 1, 2026
Merged
Brooooooklyn merged 1 commit into
Brooooooklyn merged 1 commit into
Conversation
shulaoda
force-pushed
the
04-01-fix_normalize_island_css_paths_for_windows_compatibility
branch
from
April 1, 2026 11:53
cbf041e to
ce7778d
Compare
Brooooooklyn
deleted the
04-01-fix_normalize_island_css_paths_for_windows_compatibility
branch
April 1, 2026 12:53
cpojer
pushed a commit
that referenced
this pull request
Sep 11, 2026
* fix(api): align asset upload resilience with workers-sdk (#62) Asset uploads were failing randomly because our retry logic lacked the gateway error protection that Cloudflare's workers-sdk has battle-tested. Changes: - Add gateway error (524) special handling: 5 "free" retries before counting against the attempt limit, with separate exponential backoff (5s base vs 1s) and automatic concurrency throttle from 3 to 1 - Switch from sequential to parallel bucket uploads (concurrency=3) using a lightweight semaphore (no npm deps, CF Worker compatible) - Add JWT expiration detection with actionable error messaging when upload sessions time out - Throw AssetUploadError with HTTP status for structured error handling - Increase effective retries from 5 to 6 total attempts per bucket, matching workers-sdk MAX_UPLOAD_ATTEMPTS=5 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(api): simplify asset upload code after review - Pre-compute base64 entries once per bucket instead of re-encoding on every retry attempt - Fix isJwtExpired to handle base64url encoding (CF JWTs use url-safe chars) - Replace buckets.flat().length with buckets.some() to avoid temp array - Trim narrating comments that restate the code, keep only non-obvious constraints Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): close remaining alignment gaps with workers-sdk - Retry malformed 2xx responses instead of silently accepting them. Wrangler's fetchResult throws on non-JSON bodies; we now validate the response has a result key and throw AssetUploadError if not. - Remove 4xx fail-fast escape hatch — all errors are now retried (matching Wrangler), which handles transient 429/401 from CF edge. - Rethrow original error when retries are exhausted instead of a generic message, preserving status and CF response details for debugging (matching Wrangler's throw e). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): correct off-by-one in gateway retry comments The increment-before-check pattern (matching Wrangler exactly) yields 4 truly free gateway retries, not 5. The code was correct but comments were misleading. Fix all comments to accurately describe the retry math. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): remove isFinalBucket check broken under concurrency With parallel bucket uploads, the highest-index bucket may arrive at CF before slower earlier buckets. CF returns { result: {} } (no JWT yet) because not all hashes have been received — this is normal, not an error. The isFinalBucket check was treating it as a failure and burning retry budget on valid responses. CF returns the completion JWT to whichever bucket chronologically completes the full upload set, not the highest-index one. Wrangler has no isFinalBucket concept — it just collects res.jwt from any bucket. Malformed 2xx responses (CF edge-node bug) are already caught by the postAssetUpload validation added earlier. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(api): convert recursive doUpload to iterative while loop Replace recursive return doUpload() with a while(true) loop. Max depth was only 9 frames (not dangerous), but the loop is easier to follow given the interplay between attempts, bucketGatewayErrors, and MAX_GATEWAY_ERRORS. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): tolerate late bucket failures once completion JWT is obtained With parallel uploads, one bucket may return the completion JWT (CF confirmed all hashes received) while another in-flight bucket later errors due to transient edge/auth issues. Promise.all would reject the entire deploy even though the upload succeeded. Switch to Promise.allSettled and only throw if no completion JWT was captured. Once CF returns the JWT, the upload is definitively complete regardless of client-side bucket errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(api): rename MAX_UPLOAD_ATTEMPTS to MAX_UPLOAD_RETRIES The constant is used as a max-retries ceiling (attempts >= N), not a total attempts count. The old name implied 5 total attempts but the code produces 6 total tries. MAX_UPLOAD_RETRIES matches the codebase convention (retryWithBackoff's maxRetries parameter). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): reacquire semaphore slot per retry attempt Previously each bucket held its slot for the entire lifetime including all retries, so 3 concurrent buckets continued retrying in parallel after a 524 throttle — defeating the concurrency reduction. Now the slot is released before backoff and reacquired before each retry attempt. After concurrency drops to 1, retries across all buckets are properly serialized, reducing pressure on CF. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): defer base64 encoding until slot is acquired Base64 encoding happened before acquireSlot(), so all buckets encoded concurrently regardless of the concurrency limit. This could spike memory with all base64 strings held at once. Move encoding inside the concurrency-limited section via lazy init: entries are computed once on first slot acquisition and reused for retries. Memory is now bounded by concurrency * bucket_size. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): release slot via try/finally and short-circuit on JWT Two fixes: - Wrap the entire attempt body (encoding + upload) in try/finally to guarantee releaseSlot() runs even if base64 encoding or arrayBuffer throws. Previously a throw during encoding would leak the slot and deadlock queued buckets. - Check completionJwt at the top of the retry loop so remaining bucket retries short-circuit immediately once any bucket receives the JWT, instead of waiting through full backoff cycles. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(api): prevent partial entries cache on encoding failure Build base64 entries into a temporary array and only assign to the cached entries variable after the loop completes. Previously, if arrayBuffer() threw mid-loop, entries would be a partially-filled array that retries would reuse (arrays are truthy), silently uploading incomplete data. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
normalizePathto convert backslashes to forward slashes on WindowsTest plan
pnpm checkto verify no type errors