nodejs / nodejs/node

wasm: streaming APIs accept non-Uint8Array response body chunks

Offen
#64,669 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den Einstiegspunkten WebAssembly.compileStreaming() und WebAssembly.instantiateStreaming() sowie den referenzierten WPT-Tests wasm/webapi/wasm_stream_compile_test.any.js und wasm/webapi/wasm_stream_instantiate_test.any.js. Reproduziere den ArrayBuffer-Chunk-Fall aus dem Bericht und überprüfe anschließend, dass Antwort-Chunks, die keine Uint8Array sind, mit einem TypeError abgelehnt werden, während gültige Chunks weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, wasm
Bereich
api
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
65/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.