wasm: streaming APIs accept non-Uint8Array response body chunks
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con los puntos de entrada WebAssembly.compileStreaming() y WebAssembly.instantiateStreaming() y las pruebas WPT referenciadas, wasm/webapi/wasm_stream_compile_test.any.js y wasm/webapi/wasm_stream_instantiate_test.any.js. Reproduce el caso de fragmentos ArrayBuffer del informe y, después, verifica que los fragmentos de respuesta que no sean Uint8Array se rechacen con un TypeError, mientras que los fragmentos válidos sigan funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, wasm
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 65/100