nodejs / nodejs/node

wasm: streaming APIs accept non-Uint8Array response body chunks

オープン
#64,669 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

Version

latest main branch

Platform
7.1.3-arch1-3
Subsystem

wasm

What steps will reproduce the bug?
const bytes = new Uint8Array([
  0x00, 0x61, 0x73, 0x6d, // \0asm
  0x01, 0x00, 0x00, 0x00, // version 1
]);

const stream = new ReadableStream({
  start(controller) {
    controller.enqueue(bytes.buffer); // ArrayBuffer, not Uint8Array
    controller.close();
  },
});

const response = new Response(stream, {
  headers: {
    'Content-Type': 'application/wasm',
  },
});

WebAssembly.compileStreaming(response).then(
  () => console.log('unexpectedly compiled'),
  (error) => console.error('rejected:', error),
);
How often does it reproduce? Is there a required condition?

Every

What is the expected behavior? Why is that the expected behavior?

Fetch body consumption requires every chunk read from the response body to be a Uint8Array. Other values, including ArrayBuffer, DataView, and other typed arrays, should cause the operation to reject with a TypeError.

What do you see instead?

WebAssembly.compileStreaming() and WebAssembly.instantiateStreaming() accept response bodies whose
ReadableStream produces non-Uint8Array chunks.The WebAssembly module is compiled successfully, even though the response body produces an ArrayBuffer chunk.

Additional information

Refs: https://github.com/web-platform-tests/wpt/blob/master/wasm/webapi/wasm_stream_compile_test.any.js#L80-L93
Refs: https://github.com/web-platform-tests/wpt/blob/master/wasm/webapi/wasm_stream_instantiate_test.any.js#L79-L92

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

WebAssembly.compileStreaming() と WebAssembly.instantiateStreaming() のエントリーポイント、および参照されている WPT テスト wasm/webapi/wasm_stream_compile_test.any.js と wasm/webapi/wasm_stream_instantiate_test.any.js から始めます。報告にある ArrayBuffer チャンクのケースを再現し、その後、Uint8Array ではないレスポンスチャンクが TypeError で拒否される一方で、有効なチャンクは引き続き動作することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, wasm
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。