node:buffer: Buffer.alloc(size, fill, encoding) throws when fill is a number or a Buffer
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, typescript
調査の方向性
src/node/internal/internal_buffer.tsを読み、alloc()とそのbuffer.fill()の呼び出しに注目してください。fillが文字列の場合と、数値またはBufferの場合で、encoding引数がどのように渡されるかを比較し、issueに示されている3つの非文字列ケースの回帰テストを追加してください。完了条件は、これらのケースがNode.jsの出力と一致し、文字列のケースも引き続き動作することです。
索引モデルが issue の本文から書いたものです。
説明
Buffer.alloc(size, fill, encoding) throws ERR_INVALID_ARG_TYPE in workerd whenever fill is not a string and encoding is passed. Node.js ignores encoding in that case (per https://nodejs.org/api/buffer.html#static-method-bufferallocsize-fill-encoding, it only applies "if fill is a string") and returns the filled buffer.
worker.mjs:
import { Buffer } from "node:buffer";
const show = (f) => { try { return f().toString("hex"); } catch (e) { return `${e.code}: ${e.message}`; } };
export default { test() {
console.log(show(() => Buffer.alloc(3, 5, "utf8")));
console.log(show(() => Buffer.alloc(3, 0, "utf8")));
console.log(show(() => Buffer.alloc(3, Buffer.from([7]), "utf8")));
console.log(show(() => Buffer.alloc(3, "ab", "utf8")));
} };
config.capnp:
using Workerd = import "/workerd/workerd.capnp";
const config :Workerd.Config = (services = [(name = "main", worker = .w)]);
const w :Workerd.Worker = (
modules = [(name = "worker.mjs", esModule = embed "worker.mjs")],
compatibilityDate = "2026-11-07",
);
npx workerd test --experimental config.capnp
Actual (workerd):
ERR_INVALID_ARG_TYPE: The "start" argument must be of type number. Received type string ('utf8')
ERR_INVALID_ARG_TYPE: The "start" argument must be of type number. Received type string ('utf8')
ERR_INVALID_ARG_TYPE: The "start" argument must be of type number. Received type string ('utf8')
616261
Expected (Node.js v26.13.0):
050505
000000
070707
616261
Tested with workerd 1.20261107.1 (workerd 2026-11-07), compatibility date 2026-11-07, and src/node/internal/internal_buffer.ts on main (d85cb017).
In src/node/internal/internal_buffer.ts, alloc() calls buffer.fill(fill as any, encoding), passing encoding in the start parameter slot of fill(), which only reinterprets a string start as encoding when typeof val === 'string'.
Credit: https://ucsbplse.github.io/
- 主要言語
- C++
- スター
- 9.1k
- フォーク
- 823
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 352
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloudflare/workerd のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cloudflare/workerd#8290 ·
メンテナーはふだん 1 日以内に返信
-
Streaming TextDecoder drops U+FEFF at the start of a chunk that follows an ASCII-only chunk対応中かも @oliarmak-web が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cloudflare/workerd#8279 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
D1 bind(): typed arrays and DataView store text or an empty blob instead of their bytes対応中かも @JosephDoUrden が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
cloudflare/workerd#7785 ·
メンテナーはふだん 1 日以内に返信
-
docs: suggest adding compatibility date migration guide to README対応中かも @spideydotjs が 49 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
cloudflare/workerd#7282 ·
メンテナーはふだん 1 日以内に返信
-
[Miniflare] Cross-worker Durable Object proxy drops ctx.id.name for IDs created with idFromName()オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
cloudflare/workerd#7286 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
cloudflare/workerd の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
Vector35/binaryninja-api#8715 ·
メンテナーはふだん 2 日以内に返信
-
ai_p3 comp-database-engines
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/ClickHouse#130186 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Bugs
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openmc-dev/openmc#4222 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信