fix: implement lifecycle-owned async streams#135
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Implements the previously placeholder stream() resource as a lifecycle-owned async-iterable runtime primitive, wires it into the public @askrjs/askr/resources surface, and adds coverage (tests, docs, diagnostics, and Tier-2 benchmarking) for the new semantics.
Changes:
- Add
src/runtime/stream-operation.tsimplementingstream()with stableStreamResult, lifecycle ownership, restart/close, dependency-driven restarts, cancellation, and iterator cleanup. - Extend ownership diagnostics to track
streams, and add jsdom + type-level coverage plus a Tier-2 benchmark for latest-value emission. - Update docs and various benchmarks/examples to use the current
RouteRegistry-based boot/SSR APIs while integrating the new stream docs/examples.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/types/resource.test-d.ts | Updates type tests to validate the new stream() signature and exported types. |
| tests/jsdom/runtime/ownership-diagnostics.test.tsx | Asserts ownership diagnostics plateau includes streams and returns to baseline on cleanup. |
| tests/jsdom/resources/stream.test.tsx | Adds jsdom lifecycle tests covering commit-start, promised sources, initialValue/stale, restart/close, deps behavior, cleanup/late isolation, and SSR non-execution. |
| tests/checks/docs/public-api-imports.test.ts | Updates doc checks to reflect stream() no longer being a placeholder and permits stream examples. |
| test-utils/playwright-app/src/main.tsx | Updates benchmark app SSR/hydration scenario to use a RouteRegistry. |
| src/runtime/stream-operation.ts | Introduces the lifecycle-owned async stream runtime and public StreamResult/StreamStatus types. |
| src/runtime/ownership-diagnostics.ts | Adds streams to tracked ownership diagnostics. |
| src/runtime/operations.ts | Re-exports stream() and related types from the runtime operations surface. |
| src/runtime/lifecycle-operations.ts | Removes the prior stream() stub placeholder implementation. |
| src/resources/index.ts | Exposes stream() and stream types from the @askrjs/askr/resources entry point. |
| docs/reference/resources.md | Replaces placeholder docs with real stream() semantics and an adapter example. |
| docs/reference/api.md | Updates the API overview to treat stream as a real resource helper. |
| docs/guides/resources.md | Adds a guide section explaining async-iterable streams and adapter responsibilities. |
| benches/tier4/tier4-integration-router-app.tsx | Migrates Tier-4 router bench to RouteRegistry boot API. |
| benches/tier2/tier2-subsystem-stream-latest-value.tsx | Adds Tier-2 benchmark for emitting one stream item and committing its DOM update. |
| benches/tier2/tier2-subsystem-ssr-streaming.tsx | Migrates SSR streaming bench to RouteRegistry. |
| benches/tier2/tier2-subsystem-ssr-static-batch.ts | Migrates SSG static batch bench to RouteRegistry. |
| benches/tier2/tier2-subsystem-ssr-layout-route.ts | Migrates SSR layout route bench to RouteRegistry fixture. |
| benches/tier2/tier2-subsystem-ssr-concurrent-isolation.ts | Migrates concurrent SSR isolation bench to RouteRegistry fixture. |
| benches/tier2/tier2-subsystem-router-navigation.tsx | Migrates router navigation bench to RouteRegistry boot API. |
| benches/tier2/tier2-subsystem-router-guard-execution.tsx | Updates guard bench to current auth/registry APIs (@askrjs/auth, registry-based resolution). |
| benches/tier2/tier2-subsystem-hydration-verify-markup.tsx | Updates hydration verification bench imports and switches to registry-based fixture. |
| benches/shared/_shared.tsx | Updates shared benchmark fixtures to carry RouteRegistry and align SSG route config naming (handler). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
/copilot review |
Contributor
Author
|
/copilot review |
Contributor
Author
|
/copilot review |
Contributor
Author
|
/copilot review |
Contributor
Author
|
@copilot review |
Comment on lines
+270
to
+274
| function createSnapshot<T>(options: StreamOptions<T>): StreamResult<T> { | ||
| const hasInitialValue = Object.prototype.hasOwnProperty.call( | ||
| options, | ||
| 'initialValue' | ||
| ); |
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.
Closes #134
Summary
stream()placeholder with a component-owned async-iterable runtimeStreamResult, status, restart/close, dependency restart, cancellation, and iterator cleanup semanticsValidation
npm run typechecknpm run buildnpm run test:publintnpm run pack:checknpm run test:types