Skip to content

Fix/response clone#142

Merged
godronus merged 10 commits into
mainfrom
fix/response-clone
Jun 11, 2026
Merged

Fix/response clone#142
godronus merged 10 commits into
mainfrom
fix/response-clone

Conversation

@godronus

@godronus godronus commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator
  • Added tests for Response.clone() -- ( Refactored test-app as apart of this work )
  • Added context/PATCHES.md for how to build FastEdge including our StarlingMonkey fixes

PR's upstream: If they will not merge, we will turn these into override's on our side:

bytecodealliance/StarlingMonkey#312
bytecodealliance/StarlingMonkey#313

For now we just keep them in our fork and wait and see...

godronus added 9 commits June 8, 2026 15:31
Bump the StarlingMonkey submodule from 0.3.0 (9dda8ba) to the tip of
godronus/gcore/integration (84f5d52), which carries two pending upstream
patches on top of 0.3.0:

  - feat(fetch): implement Response.clone() (PR #312)
  - fix(fetch): body.blob() sets Blob.type from Content-Type header (issue #311)

Add context/PATCHES.md documenting the applied patches, their upstream
PR/issue links, and the rebase procedure for future StarlingMonkey bumps.
Update CONTEXT_INDEX.md and CLAUDE.md to make the file discoverable.
…on tests

Implement Response.clone() in the StarlingMonkey runtime and add blob.type
propagation from Content-Type headers. Both fixes are applied via the
godronus/gcore/integration fork branch (SHA 84f5d52) pending upstream review
of PR #312 and issue #311.

Expose Response.clone() in types/globals.d.ts (instance method, previously
commented out). Update KNOWN_LIMITATIONS.md to reflect the implementation.

Restructure integration-tests/test-application from a single flat JS file
into a typed, extensible architecture:
- Convert to TypeScript with Hono routing
- Split into handlers/ (WASM context) and checks/ (Node.js, auto-discovered)
- routes.ts as single source of truth for route paths and test names
- Build artefacts consolidated under dist/ (one .gitignore entry)
- Add temporary Response.clone() prod-invocation guard — remove when
  PR #312 merges upstream and submodule is rebased

Add pnpm test:app:build and test:app:check scripts for local development.
Add context/PATCHES.md documenting the integration branch, rebase procedure,
and test guard removal checklist.
…k runner

Add tsconfig.json for the test application so fastedge-build resolves
SDK types directly from ../../types rather than the missing installed
package. Pass --tsconfig in build-test-app.js and create-test-app.js.

Fix run-test-app-checks.js: remove --bundle=false (incompatible with
--external), switch to --bundle so relative imports (routes.ts) are
inlined into each check file, and fix ESLint errors (regex u flag,
await-in-loop, no-plusplus, catch param naming, dynamic import comment).
…ation tests

Add four test scenarios covering the full clone surface:
- Constructed response text() on both branches (basic correctness)
- Constructed response getReader() + mutation guard: drain original, fill(0)
  all chunks, verify clone reads independently
- Incoming fetch() text() on both branches (HttpIncomingBody materialisation)
- Incoming fetch() getReader() + mutation guard: the precise original bug
  scenario — host-backed body, both branches via getReader()

Tests 2 and 4 currently fail: the tee implementation enqueues the same
Uint8Array reference to both branches rather than cloning each chunk, so
fill(0) on the original's chunks corrupts the clone's queued data. This is
a separate bug from the materialisation fix in PR #312 and blocks release.

Update KNOWN_LIMITATIONS.md and CONTEXT_INDEX.md to document the tee chunk
independence bug and mark Response.clone() as partially implemented.
Copilot AI review requested due to automatic review settings June 9, 2026 17:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SDK’s declared Fetch API surface to include Response.clone() and expands the “production invocation” test application + workflow to validate Response.clone() behavior end-to-end against a deployed FastEdge WASM app. It also adds internal context docs describing StarlingMonkey patching and updates testing/documentation indices accordingly.

Changes:

  • Expose Response.clone() in types/globals.d.ts and remove now-stale limitation notes.
  • Refactor/expand the prod-invocation test application into a TS + Hono structure with auto-discovered Node check modules, including a comprehensive Response.clone() guard.
  • Update CI workflow/scripts and internal context docs to support the new test app layout and patch-tracking process.

Reviewed changes

Copilot reviewed 31 out of 35 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
types/globals.d.ts Adds Response.clone() to the public type surface.
scripts/run-test-app-checks.js Local runner: bundles check modules and runs them against a deployed app URL.
scripts/build-test-app.js Local builder: compiles the prod-invocation test app to WASM via fastedge-build.
runtime/fastedge/build.sh Builds StarlingMonkey runtime with parallelism based on CPU count.
pnpm-lock.yaml Lockfile updates for added dependencies/metadata.
package.json Adds local prod-invocation test scripts and hono dev dependency.
integration-tests/test-application/types.ts Shared types for handler/check modules.
integration-tests/test-application/tsconfig.json TS config for the prod-invocation test app/checks source.
integration-tests/test-application/test-app.ts New TS entrypoint using Hono to route to handlers.
integration-tests/test-application/test-app.js Removes the prior single-file JS test app implementation.
integration-tests/test-application/routes.ts Central route/name constants for handlers and checks.
integration-tests/test-application/README.md Documents the prod-invocation test app structure and workflows.
integration-tests/test-application/handlers/env.ts Handler: env var smoke check endpoint.
integration-tests/test-application/handlers/outbound-fetch.ts Handler: outbound fetch behavior endpoint.
integration-tests/test-application/handlers/secret.ts Handler: secret injection endpoint.
integration-tests/test-application/handlers/echo.ts Handler: request echo endpoint.
integration-tests/test-application/handlers/response-clone.ts Handler: server-side Response.clone() multi-scenario guard producing JSON results.
integration-tests/test-application/handlers/multi-chunk-source.ts Helper handler: serves multi-chunk streaming body for clone isolation tests.
integration-tests/test-application/checks/env.ts Node check: validates build SHA from deployed app.
integration-tests/test-application/checks/outbound-fetch.ts Node check: validates outbound fetch behavior.
integration-tests/test-application/checks/secret.ts Node check: validates secret value injection.
integration-tests/test-application/checks/echo.ts Node check: validates request method/headers/body echo.
integration-tests/test-application/checks/response-clone.ts Node check: validates all Response.clone() guard assertions.
integration-tests/test-application/.gitkeep Placeholder file retained in test-application directory.
context/PATCHES.md Internal patch tracking + rebase procedure for StarlingMonkey fork/patches.
context/KNOWN_LIMITATIONS.md Removes the resolved Response.clone() limitation entry.
context/development/TESTING_GUIDE.md Clarifies testing layers and adds prod-invocation test commands.
context/CONTEXT_INDEX.md Index updates: adds PATCHES.md and removes stale clone limitation note.
context/CHANGELOG.md Adds entries describing the clone work and prod-guard expansion.
CLAUDE.md Adds a pointer to PATCHES.md for StarlingMonkey submodule bump procedure.
.gitignore Ignores integration-tests/test-application/dist/ artifacts.
.github/workflows/prod-invocation.yaml Updates workflow to deploy dist/test-app.wasm and clean dist/.
.github/scripts/prod-invocation/create-test-app.js Builds TS test app to WASM and bundles check modules to dist/checks.
.github/scripts/prod-invocation/invoke-test-app.js Runs all auto-discovered check modules with retry logic.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread .github/scripts/prod-invocation/invoke-test-app.js
Comment thread context/PATCHES.md
Comment thread runtime/fastedge/build.sh
@godronus godronus requested a review from qrdl June 9, 2026 17:32
@godronus godronus merged commit 36cf4c4 into main Jun 11, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants