Sandbox browser demo handler execution#8
Open
mmkal wants to merge 3 commits into
Open
Conversation
commit: |
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
Stacked follow-up on #7. The browser demo no longer runs editable handler source in the main page context:
docs/browser-demo-handler-worker.js, a static dedicated Web Worker for compiling/running handlersBase PR: #7
Verification
node --check docs/browser-demo.jsnode --check docs/browser-demo-client.jsnode --check docs/browser-demo-handler-worker.jspnpm run checkpnpm testpassed: 29 tests across 3 filesResponse, string,Blob,Uint8Array, andReadableStreamReadableStreamresponses resolve before the first body chunk and deliver later chunks incrementallywrangler devon127.0.0.1:8788, sent/health, got200 OK, and confirmed request/handler/response logsNote
Medium Risk
Moderate risk: rewires the browser demo request/response path to cross a Worker boundary (streaming, transferables, error handling), which could introduce subtle runtime/compatibility issues, but it’s limited to static docs/demo assets.
Overview
Moves the browser demo’s editable fetch handler execution out of the page and into a dedicated same-origin Web Worker, so user-provided handler code no longer runs in the DOM context.
The demo now validates/executes handler source by posting serialized requests into the worker, streaming response bodies back in chunks (using transferable
ReadableStreams when supported), and propagating handler logs and compile/runtime errors back to the existing UI with a 30s timeout guard. Documentation/UX text is updated to reflect the new trust/isolation model, and a task completion note is added.Reviewed by Cursor Bugbot for commit 0680a72. Bugbot is set up for automated code reviews on this repo. Configure here.