Skip to content

docs: Making something stream says each thing once, and covers failures and data from outside HttpClient - #111

Merged
ChristopherPHolder merged 1 commit into
mainfrom
docs/making-something-stream
Nov 28, 2026
Merged

ChristopherPHolder merged 1 commit into
mainfrom
docs/making-something-stream

Conversation

@ChristopherPHolder

Copy link
Copy Markdown
Collaborator

Closes #103.

Said once

"Rules" and "Consequences" were two lists that made the same points: the shell is sent once (three times, counting step 1), order follows the network, the placeholder paints first. They are one list now, each point said once. The movie app's details ("genre links in a 43 KB shell", "d0", "the cast list") are gone, since the reader hasn't seen that app. Each rule now says what to do as well. The #rules and #2-load-its-data-with-httpclient anchors the Analog guide links to are unchanged.

Templates use a ```angular-html fence. Oxfmt formats those the Angular way, where it had flattened the ```html one.

When a request fails

This is a new section:

  • An error state per block, with catchError into a value for each outcome. A toSignal() that errors throws when it's read.
  • What happens on each side:
    • The server streams the error state.
    • The browser repeats the request itself, because Angular's transfer cache only keeps successful responses (transferCacheInterceptorFn stores HttpResponse events only), and the block shows what that returns.
  • timeout(), for a request that would otherwise keep the response open.

I ran this in a scratch copy of example-node, with a backend that answers 500 on the server and 200 in the browser. It was a dev build in headless Chrome, loaded twice. The chunk carried the error state at 2 s, the browser made the request once and showed its result, and there were no hydration errors.

Data from outside HttpClient

This is also new:

  • resource() and httpResource() hold the shell back, which matches what docs: Analog's streaming SSR compared with this library, from one page sent through both #107 found.
  • With Zone.js, fetch() and timers hold the shell back the same way.
  • Zoneless, fetch() or an SDK's promise isn't waited for: the block goes out as its loading state, and the browser loads the data itself.
  • A streamed(key, load) helper streams such data anyway. It tracks load() with SERVER_REQUEST_TRACKER on the server and puts the result in TransferState, which every chunk carries. In the browser it waits on STREAM_HYDRATION_CLIENT.released(key) and reads the state.

I checked the helper the same way, zoneless, with a promise that settles after 2 s. The chunk arrived at 2 s with the value in its state, the block hydrated, and the browser never called load() (counter at 0, both loads). I haven't checked it with Zone.js, and the page says so.

Both scratch setups are reverted; example-node is unchanged.

Checked

  • vp check: 0 errors.
  • pnpm nx build docs: every page prerenders, and the link and heading checks pass, including reference/core.md#server_request_tracker.

…es and data from outside HttpClient

- Rules and Consequences are one list, each point once, without the
  movie app's details.
- Templates use the angular-html fence, which Oxfmt indents properly.
- When a request fails: an error state per block, what the server and
  the browser each do, and timeout() for a request that never answers.
- Data from outside HttpClient: what resource(), fetch() and SDKs do,
  and a streamed() helper over SERVER_REQUEST_TRACKER and TransferState.

Closes #103
@ChristopherPHolder
ChristopherPHolder merged commit ff28111 into main Nov 28, 2026
1 check passed
@ChristopherPHolder
ChristopherPHolder deleted the docs/making-something-stream branch November 28, 2026 08:44
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.

docs: Making something stream says each thing once, and covers data from outside HttpClient and failed requests

1 participant