Skip to content

fix: implement lifecycle-owned async streams#135

Merged
smiggleworth merged 14 commits into
mainfrom
fix/async-stream-runtime
Jul 26, 2026
Merged

fix: implement lifecycle-owned async streams#135
smiggleworth merged 14 commits into
mainfrom
fix/async-stream-runtime

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Closes #134

Summary

  • replace the documented stream() placeholder with a component-owned async-iterable runtime
  • expose stable StreamResult, status, restart/close, dependency restart, cancellation, and iterator cleanup semantics
  • add ownership, type, SSR, lifecycle, docs, packed-artifact, and Tier-2 benchmark coverage

Validation

  • npm run typecheck
  • focused jsdom lifecycle/resource/ownership tests
  • docs public-surface checks
  • npm run build
  • npm run test:publint
  • npm run pack:check
  • npm run test:types
  • focused Tier-2 stream benchmark

Copilot AI review requested due to automatic review settings July 26, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts implementing stream() with stable StreamResult, 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.

Comment thread src/runtime/stream-operation.ts Outdated
@smiggleworth

Copy link
Copy Markdown
Contributor Author

/copilot review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.

@smiggleworth

Copy link
Copy Markdown
Contributor Author

/copilot review

@smiggleworth

Copy link
Copy Markdown
Contributor Author

/copilot review

@smiggleworth

Copy link
Copy Markdown
Contributor Author

/copilot review

@smiggleworth

Copy link
Copy Markdown
Contributor Author

@copilot review

@smiggleworth
smiggleworth merged commit 28f2a44 into main Jul 26, 2026
7 checks passed
@smiggleworth
smiggleworth deleted the fix/async-stream-runtime branch July 26, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comment on lines +270 to +274
function createSnapshot<T>(options: StreamOptions<T>): StreamResult<T> {
const hasInitialValue = Object.prototype.hasOwnProperty.call(
options,
'initialValue'
);
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.

Implement lifecycle-owned async-iterable stream() runtime

2 participants