Skip to content

feat!: boolean-or-object event stream options and clearer export names - #185

Merged
dinwwwh merged 4 commits into
mainfrom
claude/sharp-brahmagupta-ekvj5s
Nov 6, 2026
Merged

dinwwwh merged 4 commits into
mainfrom
claude/sharp-brahmagupta-ekvj5s

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 6, 2026

Copy link
Copy Markdown
Member

Follows middleapi/orpc#2428: a feature is configured by one option that takes true/false or an object, so it can gain settings later without another rename. Also tidies option typing and renames a few unclear exports.

Breaking changes

Event stream options (fetch, node, and every adapter's eventStream option)

Before After (default true)
initialComment: { enabled?, comment? } initialComment?: boolean | { comment? }
keepAlive: { enabled, interval?, comment? } keepAlive?: boolean | { interval?, comment? }
// before
toFetchResponse(res, { eventStream: { keepAlive: { enabled: false } } })
// after
toFetchResponse(res, { eventStream: { keepAlive: false } })

The object shapes are exported as ToEventStreamInitialCommentOptions and ToEventStreamKeepAliveOptions (also re-exported from @standard-server/node).

Renamed exports

Removed Use instead Why
ErrorEvent, ErrorEventOptions (core) EventStreamErrorEvent, EventStreamErrorEventOptions ErrorEvent shadows the global ErrorEvent; a missing import silently type-checks against the global and instanceof stops matching
assertEventStreamMessageName (core) assertEventStreamMessageEvent named after the event field it checks, like its Id / Retry / Comment siblings
canWriteToNodeResponse (node) canWriteNodeHttpResponse matches NodeHttpResponse, toNodeHttpBody
getNodeResponseError (node) getNodeHttpResponseError same
isNodeResponseDisconnectError (node) isNodeHttpResponseDisconnectError same
isTypescriptObject (shared) isNonPrimitive says what it checks: a non-null object or a function

Non-breaking

  • Optional option properties now include | undefined, so callers using exactOptionalPropertyTypes can forward a possibly undefined value: eventStream, peer codec prefix, getOrBind's bind, EventStreamErrorEvent's message.
  • fetch toStandardBody defaults options to {} like the other adapters; redundant options?. chaining removed.

Downstream

oRPC needs updates when it bumps standard-server: the initialComment / keepAlive examples in its handler, link, adapter and Nest docs and from-v1.mdx, packages/client/src/adapters/fetch/rpc-link.test.ts, and its uses of ErrorEvent and isTypescriptObject.

Testing

pnpm format, pnpm check, tsc and pnpm test (1486 tests) pass. Added a test that true enables the default initial comment and keep-alive.


Generated by Claude Code

…oolean-or-object

Follows middleapi/orpc#2428: a feature is configured by a single option that
takes `true`/`false` or an object, so it can gain more settings later without
another rename.

- `initialComment: { enabled, comment }` becomes
  `initialComment?: boolean | { comment? }` (default `true`).
- `keepAlive: { enabled, interval, comment }` becomes
  `keepAlive?: boolean | { interval?, comment? }` (default `true`).
- The object shapes are exported as `ToEventStreamInitialCommentOptions` and
  `ToEventStreamKeepAliveOptions` (re-exported from node).

Applies to every adapter's `eventStream` option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7Q9JBMYWnu5oKt7xQ8
…options

Optional option properties now include `| undefined`, matching the rest of the
codebase, so callers with `exactOptionalPropertyTypes` can forward a possibly
undefined value: `eventStream`, peer codec `prefix`, `getOrBind` `bind`, and
`ErrorEvent` `message`.

Also default fetch `toStandardBody` options to `{}` like the other adapters, and
drop the redundant optional chaining on already-defaulted options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7Q9JBMYWnu5oKt7xQ8
… aliases

- node: `canWriteToNodeResponse`, `getNodeResponseError` and
  `isNodeResponseDisconnectError` become `canWriteNodeHttpResponse`,
  `getNodeHttpResponseError` and `isNodeHttpResponseDisconnectError`, matching
  `NodeHttpResponse` and `toNodeHttpBody`.
- core: `assertEventStreamMessageName` becomes `assertEventStreamMessageEvent`,
  after the `event` field it checks, like its `Id`/`Retry`/`Comment` siblings.
- core: `ErrorEvent` / `ErrorEventOptions` become `EventStreamErrorEvent` /
  `EventStreamErrorEventOptions`, so a missing import no longer silently falls
  back to the global `ErrorEvent`.
- shared: `isTypescriptObject` becomes `isNonPrimitive`.

The old names stay exported as `@deprecated` aliases of the new ones, so
nothing breaks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7Q9JBMYWnu5oKt7xQ8
…xports

Drops the old names kept by the previous commit:

- core: `ErrorEvent`, `ErrorEventOptions`, `assertEventStreamMessageName`
- node: `canWriteToNodeResponse`, `getNodeResponseError`,
  `isNodeResponseDisconnectError`
- shared: `isTypescriptObject`

Use `EventStreamErrorEvent`, `EventStreamErrorEventOptions`,
`assertEventStreamMessageEvent`, `canWriteNodeHttpResponse`,
`getNodeHttpResponseError`, `isNodeHttpResponseDisconnectError` and
`isNonPrimitive` instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7Q9JBMYWnu5oKt7xQ8
@pkg-pr-new

pkg-pr-new Bot commented Nov 6, 2026

Copy link
Copy Markdown
@standard-server/aws-lambda

npm i https://pkg.pr.new/@standard-server/aws-lambda@185

@standard-server/core

npm i https://pkg.pr.new/@standard-server/core@185

@standard-server/fastify

npm i https://pkg.pr.new/@standard-server/fastify@185

@standard-server/fetch

npm i https://pkg.pr.new/@standard-server/fetch@185

@standard-server/node

npm i https://pkg.pr.new/@standard-server/node@185

@standard-server/peer

npm i https://pkg.pr.new/@standard-server/peer@185

@standard-server/shared

npm i https://pkg.pr.new/@standard-server/shared@185

commit: 1488668

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/sharp-brahmagupta-ekvj5s (1488668) with main (a382274)

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Boolean-or-object event-stream options — initialComment and keepAlive in packages/fetch/src/event-stream.ts now accept boolean | <ObjectOptions> | undefined, with the object shapes exported as ToEventStreamInitialCommentOptions / ToEventStreamKeepAliveOptions and re-exported from @standard-server/node. Defaults are unchanged and coercion (!== false to disable) is consistent across both options.
  • EventStreamErrorEvent rename — the core class and options interface no longer shadow the DOM global ErrorEvent; all core, fetch, peer, adapter, and e2e call sites were updated, and the intermediate deprecated aliases were removed before shipping.
  • Node HTTP response helper renames — canWriteNodeHttpResponse, getNodeHttpResponseError, isNodeHttpResponseDisconnectError, plus the matching internal error-code set, with fastify / aws-lambda call sites updated.
  • isNonPrimitive rename — isTypescriptObject renamed in @standard-server/shared, with validators, event-stream meta, and peer call sites updated.
  • Optional-property | undefined — fetch/node eventStream, peer codec prefix, getOrBind's bind, and EventStreamErrorEventOptions.message, for exactOptionalPropertyTypes callers.
  • fetch toStandardBody default — options: ToStandardBodyOptions = {}, dropping the redundant options?. chaining.
  • Docs — core README examples and export list updated to the new names.

I also verified the rename is complete: a repo-wide search finds no remaining references to any removed identifier in source, tests, benches, playgrounds, or markdown, and pnpm check plus the full vitest suite (1486 tests) pass locally.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit ca10b64 into main Nov 6, 2026
11 checks passed
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.

2 participants