Skip to content

fix(core): avoid extending TransformStream in EventStreamDecoderStream - #78

Merged
dinwwwh merged 1 commit into
mainfrom
claude/transformstream-no-extend-936eb2
Aug 27, 2026
Merged

fix(core): avoid extending TransformStream in EventStreamDecoderStream#78
dinwwwh merged 1 commit into
mainfrom
claude/transformstream-no-extend-936eb2

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 27, 2026

Copy link
Copy Markdown
Member

EventStreamDecoderStream no longer extends TransformStream. Extending resolves the global at module-evaluation time, so merely importing @standardserver/core crashed on runtimes that don't provide TransformStream — even when the stream class was never used. The class now composes a TransformStream created in its constructor and exposes its readable/writable pair, so the global is only needed when an instance is actually constructed.

Fixes

  • Importing @standardserver/core works on runtimes without a global TransformStream; only constructing EventStreamDecoderStream requires it.
  • .pipeThrough(new EventStreamDecoderStream()) behaves exactly as before — the class satisfies ReadableWritablePair<EventStreamMessage, string>. The only observable difference is that instances are no longer instanceof TransformStream (nothing in the repo relied on that).

Testing

  • New test stubs out the global TransformStream and asserts a fresh import of the module still succeeds; verified it fails against the previous extends implementation.
  • Full workspace suite passes (59 files, 1075 tests) and tsc --noEmit is clean for core and fetch.

Extending TransformStream resolves the global at module-evaluation time,
so importing @standardserver/core crashed on runtimes without it even
when the stream class was never used. Compose a TransformStream inside
the constructor instead, deferring the global lookup to instantiation.
@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown
@standardserver/aws-lambda

npm i https://pkg.pr.new/@standardserver/aws-lambda@78

@standardserver/core

npm i https://pkg.pr.new/@standardserver/core@78

@standardserver/fastify

npm i https://pkg.pr.new/@standardserver/fastify@78

@standardserver/fetch

npm i https://pkg.pr.new/@standardserver/fetch@78

@standardserver/node

npm i https://pkg.pr.new/@standardserver/node@78

@standardserver/peer

npm i https://pkg.pr.new/@standardserver/peer@78

@standardserver/shared

npm i https://pkg.pr.new/@standardserver/shared@78

commit: 622f100

@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

  • EventStreamDecoderStream now implements ReadableWritablePair<EventStreamMessage, string> instead of extends TransformStream, composing a TransformStream in the constructor and exposing its readable/writable pair — deferring the global-after-reference until an instance is constructed.
  • New regression test stubs TransformStream to undefined and re-imports ./decoder, verifying module import no longer crashe- resolving the global at import time.

The refactor is sound: ReadableStream/WritableStream are type annotations (type-erased at compile time), so the only runtime global use is the new TransformStream(...) inside the constructor. grep confirms every caller is .pipeThrough(new EventStreamDecoderStream()) (core tests, package/fetch/src/event-stream.ts:9, README), which only needs the ReadableWritablePair shape — nothing relies on instanceof TransformStream. The new test is meaningful (the old extends impl throws on import when the global is undefined) and cleans up via onTestFinished.

Pullfrog  | View workflow run | Using DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/transformstream-no-extend-936eb2 (622f100) with main (cd7c12f)2

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.

  2. No successful run was found on main (9dd3c23) during the generation of this report, so cd7c12f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@dinwwwh
dinwwwh merged commit afdb26d into main Aug 27, 2026
5 of 10 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.

1 participant