Skip to content

fix: normalize island CSS paths for Windows compatibility - #62

Merged
Brooooooklyn merged 1 commit into
mainfrom
04-01-fix_normalize_island_css_paths_for_windows_compatibility
Apr 1, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
04-01-fix_normalize_island_css_paths_for_windows_compatibility

Conversation

@shulaoda

@shulaoda shulaoda commented Apr 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Normalize island CSS relative paths with Vite's normalizePath to convert backslashes to forward slashes on Windows
  • Applied consistently across all four framework adapters (react, solid, svelte, vue)

Test plan

  • Run pnpm check to verify no type errors
  • Test islands mode dev server on Windows and confirm CSS paths use forward slashes

@shulaoda
shulaoda force-pushed the 04-01-fix_normalize_island_css_paths_for_windows_compatibility branch from cbf041e to ce7778d Compare April 1, 2026 11:53
@Brooooooklyn
Brooooooklyn merged commit 980d99d into main Apr 1, 2026
5 of 6 checks passed
@Brooooooklyn
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>
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.

2 participants