diff options
Diffstat (limited to 'ext/web/08_text_encoding.js')
-rw-r--r-- | ext/web/08_text_encoding.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index 28f2848b8..d3f6d45fb 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -114,7 +114,14 @@ } else { input = new Uint8Array(input); } - return core.opSync("op_encoding_decode", new Uint8Array(input), { + if (input.buffer instanceof SharedArrayBuffer) { + // We clone the data into a non-shared ArrayBuffer so we can pass it + // to Rust. + // `input` is now a Uint8Array, and calling the TypedArray constructor + // with a TypedArray argument copies the data. + input = new Uint8Array(input); + } + return core.opSync("op_encoding_decode", input, { rid: this.#rid, stream: options.stream, }); |