Repository navigation
Description
Summary
A page that loads a block's data with resource() or httpResource() does not stream. A resource counts as pending work in Angular, the shell waits for whenStable(), and the page goes out in one piece once the data is in: complete, but not streamed. Only requests made directly with HttpClient stream.
httpResource() is how Angular's own docs load data now, so this is the first thing a new user runs into. Found while recording Analog's streaming SSR, compared (#107, #119): Analog's response was the same with httpResource() as with HttpClient.
What we want
A block whose data comes from a resource streams like one that uses HttpClient.get(): the shell goes out with the block in its loading state, and the block follows in a chunk when the resource has its value.
To work out
- The shell is taken when the application is stable apart from the requests the renderer follows. A resource has to become one of those, not pending work that holds the shell.
httpResource()goes throughHttpClient, sostreamHttpInterceptoralready sees its request. A plainresource()with a loader does not: it may needSERVER_REQUEST_TRACKERbehind the scenes, or stay documented as manual.- The browser must take the value from the stream and not request it again.
- Check it against every row of the compat matrix (
compat/), zoneless and with Zone.js.
Docs to change with it
Each of these says today that a resource does not stream. The PR that fixes this changes them in the same PR.
apps/docs/src/content/guides/making-something-stream.md: step "2. Load its data withHttpClient", and "Data from outsideHttpClient" (theresource()bullet, and thestreamed()helper if this case no longer needs it).apps/docs/src/content/guides/debugging.md: "The page arrives all at once", which lists a resource as a cause.apps/docs/src/content/reference/faq.md: "Does the data have to come throughHttpClient?" and "Why does my page arrive all at once?".apps/docs/src/content/reference/core.md:streamHttpInterceptorandSERVER_REQUEST_TRACKER, plus anything new in the API.apps/docs/src/content/guides/analog-streaming-ssr.md: remove "A block can load its data any way" from "What Analog does that this library does not", and fix the "What a flush waits for" row of "Side by side", the second bullet of "In short" and the last bullet of "How this was captured".libs/stream-exampleand theapps/example-*it feeds: decide whether the example page switches tohttpResource(). If it does, the snippets the runtime pages copy from it change too.README.md, where it says requests "go throughHttpClient", andAGENTS.md's "Streaming" bullet if the advice on where data belongs changes.
Done when
- A page with
httpResource()in a block streams: shell first, the block in a chunk when its data is in, hydrated from the server's HTML with no second request. Checked withcurl -Nand in a browser, on every supported Angular version. - Every doc listed above is updated in the same PR, and nothing in the docs still says a resource holds the page back.
resource()with a custom loader either streams too, or is documented as the one case that needsSERVER_REQUEST_TRACKER.
Activity
feat(core): a page that loads its data with resource() or httpResourc…