Repository navigation
fix(qwikloader): bootstrap module loader via inline import to prevent WebKit streaming delay - #9182
Piercekaoru wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 9e10436 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
@qwik.dev/core
@qwik.dev/router
@qwik.dev/utils
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
@qwik.dev/mcp
commit: |
Varixo
left a comment
There was a problem hiding this comment.
Hello! Thanks for the PR, the changes are looking good, but added small comment
| this.emitInlineScript( | ||
| `import(new URL(${JSON.stringify(qwikLoaderBundle).replaceAll('<', '\\u003C')},document.baseURI).href)` | ||
| ); |
There was a problem hiding this comment.
what about CSP rules? could you add chromium/firefox/webkit streaming e2e test with an enforced nonce-based CSP?
There was a problem hiding this comment.
Opened #9208 as a replacement for this PR, with the enforced nonce-based CSP streaming coverage requested here
- Chromium, Firefox and WebKit each run the held-stream click queue/replay test with and without
script-src 'nonce-<value>' 'strict-dynamic' - The fixture uses an enforced response header rather than report-only, and asserts zero CSP violations
- Both variants passed across all three browsers with 5 repetitions each, 30 passed with retries disabled
- As a mutation check, removing only the bootstrap nonce caused CSP rejection in all three browsers; restoring it returned 30 passed
- The full error-handling suite passed 126 tests with 6 existing skips
Local validation caveats are recorded in the new PR, including the missing optimizer bindings in the default monorepo unit run
GitHub CI on the replacement PR is still pending
|
My mistake, I'll rework the fix to avoid this |
it may work, so first add the test and see if everything is fine |
|
Closing in favour of #9208 |
What is it?
Description
WebKit can defer the evaluation of
<script async type="module" src="...">scripts while an HTML stream remains open. When an application streams HTML, this delay can cause pre-resumption user interactions (such as early clicks) to be missed because the qwikloader bootstrap script is not evaluated until the stream finishes.This change in
packages/qwik/src/server/ssr-container.tsresolves the issue:<link rel="modulepreload">to preserve early fetching behavior.<script async type="module" src="...">tag with an inline bootstrap script emitted via the existing nonce-awareemitInlineScript.document.baseURI; the server serializes the URL withJSON.stringify.<characters in the serialized URL string as\u003Cto prevent premature script tag termination.document.baseURIto preserve relative and absolute loader URL resolution.modulepreloadlink and the inline import bootstrap script.inlineandneverloader strategies untouched.@qwik.dev/core.Fixes #8891
Testing
Test environment:
Verification results:
_qwikEv.rootsfor 30s.--browser=all --repeat-each=5 --workers=1 --retries=0): 15 passed.error-handling.e2e.tssuite (including production scenarios) across Chromium, Firefox, and WebKit: 120 passed, 9 pre-existing skipped.render-api.spec.tsxandserver/ssr-container.spec.ts): 90 passed. Added render API coverage for default/explicit module modes, nonce propagation, relative/CDN URLs, and script-tag termination escaping.pnpm build.core.dev: passed.pnpm build --qwik --optimizer --qwikrouter: passed.pnpm lint.eslint(followingpnpm build --eslint),pnpm lint.prettier, andgit diff --check: passed.pnpm test.unit --maxWorkers=4reported 3961 passed, 7 failed, 18 skipped, 19 todo.qwik-vite/src/plugins/plugin.unit.tswithCannot find module '/qwik-vite/src/bindings/qwik.wasm.mjs'.ssr-container.tsto base HEAD, confirming they are unrelated to this PR.error-handling.spec.tsx; it passed in isolation and in the final bounded full run.Checklist