Repository navigation
fix: scope getPageContext() in +onAfterRenderClient to its synchronous code (vikejs/vike#3759) - #248
Conversation
…`vike@0.4.271` (vikejs/vike#3759) BREAKING CHANGE: Update Vike to 0.4.271 or above. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The Windows jobs stop at the build. CI installed Vike 0.4.259, which has no The Ubuntu jobs stop before that, at I'll open a PR that bumps |
+onAfterRenderClient and the other cumulative hooks work with vike@0.4.271 (vikejs/vike#3759)pageContext provided to a render hook (vikejs/vike#3759)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page id in `<script id="vike_pageContext">` has its slashes escaped as `\/`, so `findFirstPageId()` replaces that and not `\\/`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pageContext provided to a render hook (vikejs/vike#3759)getPageContext() in +onAfterRenderClient to its synchronous code (vikejs/vike#3759)
|
@brillout Ready for review at |
On the server, a
getPageContext()after anawaitin+onAfterRenderHtmlcan return thepageContextof another request. vike-react 0.6.32 callsprovidePageContext(pageContext)before each render hook and each function set as+headHtmlEndand alike, and Vike keeps thatpageContextuntil its queued cleanup runs. This PR calls each of them insideprovidePageContext(pageContext, fn), as you asked, sogetPageContext()returns thatpageContextonly in the hook's synchronous code. After anawait, a hook has itspageContextargument.dee1dd8fd(vikejs/vike#3759), itstest/vike-reactapp onvike previewcallCumulativeHooks.jsgetPageContext()afterawaits in+onAfterRenderHtml, 1220 overlapping pairs of requestspageContextin 20 pairsnullin all 1220examples/fullonvike devccaeb16withmainat0a83fa3merged in locally, for its Playwright bump)Update vike-react, vike-vue or vike-solid to its latest versionrequire: { vike }and thevikepeer dependency go from>=0.4.250to>=0.4.271, because a Vike without the callback form ignores the callback, so the hook would never run. vike-react 0.6.32 keeps working on that Vike release, with the warning, so Vike can be released first. The squash body:What you should see
1. Three hooks added to
examples/fullfor the run. The server prints the first two lines, and the third is the attribute+onAfterRenderClientsets on<html>:2. Local runs on
457f23c, with the releasedvike@0.4.271in the lockfile, on Node 22.23.4: build, type check (17 projects), unit tests and the format check of the tracked files exit 0, and the 19 e2e test files pass.48b928fmoves the Vike dev dependencies to^0.4.271, as the earlierchore: vike@^…commits do, andtest/sentry's too, whose type check failed on the older Vike next to this vike-react.457f23cupdates the page id assertion ofexamples/fullfor Vike 0.4.271, whose HTML escapes each slash of the page id as\/, where its.testRun.tsreplaced\\/.🤖 Generated with Claude Code