fix(Stream): avoid mutable Channel.runFold accumulator in mkUint8Array#2127
Closed
stephanschielke wants to merge 1 commit intoEffect-TS:mainfrom
Closed
fix(Stream): avoid mutable Channel.runFold accumulator in mkUint8Array#2127stephanschielke wants to merge 1 commit intoEffect-TS:mainfrom
stephanschielke wants to merge 1 commit intoEffect-TS:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 6d88699 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 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 |
dab622f to
7ed780a
Compare
Author
|
Note on CI: there are 7 pre-existing test failures on
Verified locally by running the test suite on upstream/main without this change -- same 7 failures. With this change, the count stays at 7 (zero regressions introduced). |
7ed780a to
b44edfb
Compare
b44edfb to
6d88699
Compare
This was referenced May 6, 2026
Bash tool fails with 'Attempted to assign to readonly property' in v1.14.34
anomalyco/opencode#25873
Open
Contributor
📊 JSDoc Documentation Analysis📈 Current Analysis ResultsThis comment is automatically updated on each push. View the analysis script for details. |
Contributor
Bundle Size Analysis
|
Member
|
Closing this PR as the issue is not on our end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2126
What
Stream.mkUint8Arraywas refactored in4.0.0-beta.59to useChannel.runFoldwith a mutable accumulator (acc.bytes +=,acc.arrays.push). In Bun--compile --minifybinaries, mutating an object that is passed repeatedly as the accumulator to a fold step callback throwsAttempting to define property on object that is not extensible.This does NOT reproduce with:
bun run(interpreted mode)bun build --compilewithout--minifyFix
Revert to the pre-beta.59 immutable
Channel.runFoldpattern where each fold iteration returns a newUint8Arrayinstead of mutating a shared{ bytes, arrays }object. This matches the established convention used byMultipart.collectUint8Array(line 472) and whatmkUint8Arrayitself used before beta.59.Verification
All commands run from the repo root:
pnpm --filter effect check-- zero type errorspnpm lint-fix-- zero warnings, zero errorspnpm --filter effect test run -- Stream.test.ts-- all Stream tests pass. 7 pre-existing failures in unrelated files (EffectKeepAlive, Command, OtlpMetrics) -- same count on upstream/main without this change.Tests
Added three tests for
mkUint8Array:Real-world impact
opencode v1.14.34+ crashes on every second LLM tool call in compiled binaries because
snapshot/index.tscallsStream.mkUint8Array(handle.stdout)to collectgit cat-file --batchoutput. See anomalyco/opencode#25873 and anomalyco/opencode#25867.Note
Stream.runCollect(line 9907) also mutates its fold accumulator (acc.push(chunk[i])). It may be affected by the same Bun compiled-mode behavior. Not fixing here to keep this PR focused on the confirmed crash site.