Repository navigation
fix(analog): link server calls only to the request they ran under - #405
Merged
Merged
Conversation
A render without Angular's REQUEST token, as in Analog, was linked to whichever traced request was the only one in flight. An untraced render running alongside a traced one had its server calls shown under the other page's request, and two overlapping traced renders lost their links altogether. The tracers now set the request id, or an untraced marker, in an AsyncLocalStorage shared through the SSR registry: withPangularSsr and the Node middleware run the handler inside it, and the h3 event handler enters it for the rest of the request. The interceptor reads it, keeps the first value per app so a call that loses the async context still finds its own request, and links nothing when no tracer saw the render.
Contributor
|
View your CI Pipeline Execution ↗ for commit 360fab4
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by 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.
What and why
On an Analog app, a server render has no Angular
REQUESTtoken, so the HTTP interceptor linked its calls to whichever traced request was the only one in flight. An untraced render running alongside a traced one had its server calls shown under the other page's request, and two overlapping traced renders lost their links altogether.The tracers now keep the request id (or an "untraced" marker) in an
AsyncLocalStorageshared through the SSR registry:withPangularSsrand the Node middleware run the handler inside it.pangularSsrEventHandler(h3/Nitro) enters it for the rest of the request, since the render runs after the handler returns.The storage is created with
process.getBuiltinModule('node:async_hooks'), so the app bundle gets no static Node import. Renders with Angular'sREQUEST(Express) still use the header, and nothing changes while the inspector is off.The docs limitation in the Analog guide and the SSR HTTP page is replaced with the new behaviour.
How it was verified
pnpm commit:checkpnpm format:checkpnpm typecheckpnpm test:devtools: 3053 tests pass. The 5 new tests inssr-request-context.test.ts(real h3 and Node servers with overlapping traced and untraced renders) fail before the fix.pnpm skills:checkapps/docsupdated andpnpm docs:buildpassespnpm extension:build(noapp/change)Manual check in
examples/analogdev: four traced and two untraced requests overlapping. Each traced render's call linked to its ownServer-Timingid, and the untraced renders' calls stayed unlinked.Notes for reviewers
enterWithcontext carries into the render./index.html, because Vite rewritesreq.urlbefore the tracer reads it.Summary by CodeRabbit
Bug Fixes
Documentation