GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(codemode): define Uint8Array BYTES_PER_ELEMENT by rekram1-node · Pull Request #64930 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 19, 2026

Copy link
Copy Markdown
Member

Summary

Uint8Array.BYTES_PER_ELEMENT was missing in Code Mode, on the constructor, its instances, and Buffer. Size arithmetic with it silently gave NaN. Now it is a read-only, non-enumerable 1, the same as in Bun.

[Uint8Array.BYTES_PER_ELEMENT, new Uint8Array(1).BYTES_PER_ELEMENT, Buffer.BYTES_PER_ELEMENT, 4 * Uint8Array.BYTES_PER_ELEMENT]
// Bun 1.4.4:        [1, 1, 1, 4]
// Code Mode before: [undefined, undefined, undefined, NaN]
// Code Mode after:  [1, 1, 1, 4]

The property descriptors match Bun's (writable, enumerable and configurable are all false). In Bun, Buffer inherits the constant from Uint8Array. Code Mode's Buffer constructor does not inherit from Uint8Array, so the constant is defined directly on Buffer. Making Buffer inherit would also expose Uint8Array.of, fromHex and others on it, which is out of scope here.

Testing

  • New test in packages/codemode/test/stdlib.test.ts covering the value, the descriptor, and that Object.keys(Uint8Array) stays empty.
  • Ran bun test in packages/codemode: 1785 passed. The one failure was the load-sensitive limits.test.ts "many unhandled rejections" timeout, and it passes when the file runs alone.
  • Ran bun typecheck in packages/codemode and bun run check at the repo root.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" font-family="ui-monospace,monospace" font-size="12">
<style>
.c{animation:s 4s steps(1) infinite}
.a{animation:o 4s infinite}.b{animation:o 4s infinite reverse}
@keyframes s{0%{transform:translateX(0)}25%{transform:translateX(28px)}50%{transform:translateX(56px)}75%{transform:translateX(84px)}}
@keyframes o{0%,45%{opacity:1}50%,95%{opacity:0}100%{opacity:1}}
@media (prefers-reduced-motion:reduce){.c,.a,.b{animation:none}.a{opacity:0}.b{opacity:1}}
</style>
<g opacity=".45"><rect x="16" y="14" width="28" height="22"/><rect x="44" y="14" width="28" height="22"/><rect x="72" y="14" width="28" height="22"/><rect x="100" y="14" width="28" height="22"/></g>
<rect class="c" x="16" y="14" width="28" height="22" fill="currentColor" fill-opacity=".25" stroke-width="2"/>
<g fill="currentColor" stroke="none">
<text x="16" y="56" opacity=".6">BYTES_PER_ELEMENT</text>
<text x="146" y="30" opacity=".6">step:</text>
<text class="a" x="186" y="30" opacity=".5">NaN</text>
<text class="b" x="186" y="30" font-weight="bold">1</text>
</g>
</svg>

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(codemode): define Uint8Array BYTES_PER_ELEMENT
9cb5803
opencodejr[bot]
opencodejr Bot reviewed Nov 19, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good. On the base branch, the PR's new test fails: BYTES_PER_ELEMENT is missing there. With this change it passes, and the full stdlib.test.ts passes (151 tests). tsc --noEmit is clean.

The constant is defined with the existing frozen attributes, on both the constructor and the prototype, which matches the built-in behaviour. Defining it directly on Buffer is a reasonable way to avoid making Buffer inherit from Uint8Array. The test is small and focused.

Public API: unchanged. The change only affects Code Mode's sandboxed runtime: no SDK, HTTP API, plugin, config or CLI surface is touched.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
rekram1-node merged commit 10e5856 into dev Nov 19, 2026
11 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the bytes-per-element branch November 19, 2026 18:45
@opencodejr opencodejr Bot mentioned this pull request Nov 19, 2026
fix(codemode): honor base64 alphabet, omitPadding, and lastChunkHandling options #64931
Merged
kommander added a commit that referenced this pull request Nov 19, 2026
@kommander
feat(codemode-rust): classes, ported from #64965, and BYTES_PER_ELEME…
0962708
…NT from #64930

Class declarations and expressions with constructors only new may call,
instance and static methods, accessors and fields, extends of classes and
Error types, super(...) and super.x reads, writes, calls, compound
assignments and deletes (also in object literal methods), home objects,
derived constructors' this before super() and their return rules,
Function.prototype's restricted caller and arguments, class names in
console.log, and the reference's texts for refused class syntax,
decorators and private names. An element read or written with an object
key now calls a program getter or setter, and a function under a computed
key is named by it. Uint8Array, its prototype and Buffer get
BYTES_PER_ELEMENT. #64919 changes only test hooks. Recordings regenerated
from the reference, with class cases from its tests.
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.