Repository navigation
Fix zero maxBytes handling in NodeStream - #7233
Conversation
🦋 Changeset detectedLatest commit: f00e098 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Fixes a bug in @effect/platform-node-shared where maxBytes: 0 was treated as “no limit” in NodeStream consumers due to truthiness checks, and adds regression coverage to prevent reintroduction.
Changes:
- Replace truthiness checks with explicit
undefinedchecks formaxBytesinNodeStream.toStringandNodeStream.toArrayBuffer. - Add regression tests ensuring
maxBytes: 0is enforced for both string and binary stream consumption. - Add a changeset for a patch release noting the zero-byte limit enforcement.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/platform/node-shared/src/NodeStream.ts | Fixes maxBytes: 0 handling by using !== undefined checks in both consumers. |
| packages/platform/node-shared/test/NodeStream.test.ts | Adds regression tests asserting zero-byte limits fail as expected. |
| .changeset/fix-zero-max-bytes.md | Declares a patch release entry for the behavior fix. |
Suppressed comments (1)
packages/platform/node-shared/src/NodeStream.ts:300
- When
maxBytesis exceeded, the stream is not destroyed. SinceEffect.callbackcleanup runs only on interruption, failing viaresume(Effect.fail(...))can leave the stream active and continue pushing chunks into memory even though the effect has already failed. Destroy the stream before resuming the failure, consistent with the"error"handler above.
if (maxBytesNumber !== undefined && bytes > maxBytesNumber) {
resume(Effect.fail(onError(new Error("maxBytes exceeded")) as E))
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
Type
Description
NodeStream.toStringandNodeStream.toArrayBufferacceptedmaxBytes: 0, but truthiness checks treated the value as if no limit had been supplied. Both functions therefore consumed non-empty streams even though the configured maximum was zero.This replaces the truthiness checks with explicit
undefinedchecks in both sibling implementations, preserving zero as a valid limit. Focused regression tests cover both the string and binary consumers.Validation:
vitest run packages/platform/node-shared/test/NodeStream.test.ts(12 tests passed)tsc -b tsconfig.jsonoxlint -f unixdprint checkRelated