diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 0dec915124bf30..3a3d558361e118 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -491,10 +491,18 @@ function makeTextDecoderJS() { decode(input = empty, options = kEmptyObject) { validateDecoder(this); if (isAnyArrayBuffer(input)) { - input = lazyBuffer().from(input); + try { + input = lazyBuffer().from(input); + } catch { + input = empty; + } } else if (isArrayBufferView(input)) { - input = lazyBuffer().from(input.buffer, input.byteOffset, - input.byteLength); + try { + input = lazyBuffer().from(input.buffer, input.byteOffset, + input.byteLength); + } catch { + input = empty; + } } else { throw new ERR_INVALID_ARG_TYPE('input', ['ArrayBuffer', 'ArrayBufferView'],