Skip to content

fix(router): avoid reusing consumed request body in scoped route loaders - #9234

Merged
Varixo merged 1 commit into
QwikDev:mainfrom
akasakariko:fix/issue-9157
Oct 21, 2026
Merged

Varixo merged 1 commit into
QwikDev:mainfrom
akasakariko:fix/issue-9157

Conversation

@akasakariko

Copy link
Copy Markdown
Contributor

Summary

  • getLoaderRequestEvent in packages/qwik-router/src/runtime/src/route-loaders.ts previously created scoped ancestor/layout loader requests with new Request(url, rootRequestEv.request), which attempted to reuse a POST body already consumed by actionsMiddleware and failed with TypeError: Response body object should not be disturbed or locked
  • Pass only method, headers, and signal when constructing the scoped Request so route loaders keep request metadata and abort propagation without reusing the consumed action body
  • Update packages/qwik-router/src/middleware/request-handler/handlers/loader-request-event.unit.ts to consume a POST body before scoping loaders while asserting URL/search, params, method/headers, and abort propagation
  • Add a patch changeset for @qwik.dev/router

Fixes #9157

Validation

  • Reproduced before fix with the targeted suite failing (10 passed / 1 failed with disturbed/locked body TypeError) and production playground todo HTML POST returning 500 despite saving the item
  • Focused regression in packages/qwik-router/src/middleware/request-handler/handlers/loader-request-event.unit.ts: 11 passed
  • Router unit tests: 809 passed
  • Full unit suite via corepack pnpm test.unit --run: 4043 passed, 18 skipped, 19 todo
  • Chromium Playwright suites: existing action tests 16 passed and loaders/navigation tests 79 passed
  • Build and static checks: corepack pnpm build.core.dev, corepack pnpm build.core, corepack pnpm tsc.check, targeted Prettier and ESLint, and git diff --check passed
  • Production vite preview verification: HTML and JSON POST returned 200, Chromium with JavaScript disabled submitted and rendered the new item once, and cross-origin native POST still returned 403 without saving an item

@akasakariko
akasakariko requested a review from a team as a code owner October 19, 2026 13:55
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c4be846

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@qwik.dev/router Patch
eslint-plugin-qwik Patch
@qwik.dev/mcp Patch
create-qwik Patch
@qwik.dev/devtools Patch
@qwik.dev/react Patch
@qwik.dev/utils Patch
@qwik.dev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@9234

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@9234

@qwik.dev/utils

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/utils@9234

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@9234

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@9234

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@9234

@qwik.dev/devtools

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/devtools@9234

@qwik.dev/mcp

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/mcp@9234

commit: c4be846

@Varixo Varixo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hey, thanks for this PR, lgtm

@Varixo
Varixo merged commit 1bcd4b4 into QwikDev:main Oct 21, 2026
akasakariko added a commit to akasakariko/akasakariko that referenced this pull request Oct 21, 2026
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.

[🐞] Native form POST to a routeAction$ returns 500 in a production build when a layout has a routeLoader$ (rc.0)

2 participants