Skip to content

Add .streamedOptions and .liveOptions for SSE / async-generator routes#3

Open
NeilTheFisher wants to merge 3 commits into
Frank-III:mainfrom
NeilTheFisher:feat/sse-streamed-live-upstream
Open

Add .streamedOptions and .liveOptions for SSE / async-generator routes#3
NeilTheFisher wants to merge 3 commits into
Frank-III:mainfrom
NeilTheFisher:feat/sse-streamed-live-upstream

Conversation

@NeilTheFisher
Copy link
Copy Markdown

@NeilTheFisher NeilTheFisher commented May 1, 2026

Adds two helpers for Elysia routes that return an async generator (or use sse()):

  • .streamedOptions() — built on TanStack's experimental_streamedQuery. Chunks accumulate as TChunk[]. Supports refetchMode ("append" | "reset" | "replace").
  • .liveOptions() — writes each chunk to cache via setQueryData; resolves to the latest chunk.

Both are also exposed on createEdenTQUtils. TChunk inferred via AsyncIterableElement<ExtractData<Res>>.

Continues from #2 (closed due to branch recreation).


Note

Medium Risk
Adds new query helpers built on TanStack Query’s experimental streaming API and introduces cache-writing behavior for live streams, which could affect client query lifecycle/refetch semantics. Also renames/repackages the library as a scoped fork, which may impact consumers’ import paths and publishing.

Overview
Adds SSE/async-generator route support via new .streamedOptions() and .liveOptions() helpers on both the Eden method decorators and createEdenTQUtils, enabling TanStack Query queries to consume AsyncIterable responses (including Elysia sse() payloads).

Implements streamed accumulation using experimental_streamedQuery with a configurable refetchMode, and implements live streaming by writing each chunk to cache with setQueryData and resolving to the final chunk (erroring if nothing is yielded).

Updates types/exports and documentation accordingly, adds coverage for streamed/live behavior, and adjusts package metadata (scoped rename, version bump) plus dependency/lockfile updates (including removal of bun.lock).

Reviewed by Cursor Bugbot for commit 6c350d8. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6c350d8. Configure here.

Comment thread package.json
"elysia": "^1.4.28",
"expect-type": "^1.3.0",
"typescript": "^6.0.2",
"typescript": "^6.0.3",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Peer dependency too loose for new API requirements

High Severity

The peerDependencies for @tanstack/query-core is ">=5.0.0", but the new code has a top-level import { experimental_streamedQuery } which was only added in v5.86.0, and liveQuery uses context.client on QueryFunctionContext which was added around v5.62.0. Any user with a @tanstack/query-core version between 5.0.0 and 5.85.x will hit a runtime import failure when loading the library, even if they never use the streaming features.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6c350d8. Configure here.

NeilTheFisher and others added 3 commits May 4, 2026 12:10
* feat: add .streamedOptions and .liveOptions for SSE/async-generator routes

- streamedOptions accumulates yielded chunks into TChunk[] via TanStack
  experimental_streamedQuery (refetchMode passthrough).
- liveOptions writes each chunk to setQueryData and resolves to the latest
  chunk; mirrors orpc's liveQuery semantics.
- Added type signatures on EdenTQMethod and EdenTQUtilsMethod, with chunk
  inference via AsyncIterableElement<ExtractData<Res>>.
- Renamed package to @neilthefisher/eden-tanstack-query, bumped to 0.2.0.
- Added tests covering accumulation, last-chunk replacement, and the
  non-iterable-route guard.
- Documented the new helpers in README.

* test: cover Elysia sse() helper for streamed and live options

---------

Co-authored-by: Neil Fisher <nfisher@summit-tech.ca>
@NeilTheFisher NeilTheFisher force-pushed the feat/sse-streamed-live-upstream branch from 6c350d8 to fab2e04 Compare May 4, 2026 16:10
@cursor
Copy link
Copy Markdown

cursor Bot commented May 4, 2026

You have used all of your free Bugbot PR reviews.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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.

1 participant