diff --git a/lib/buffer.js b/lib/buffer.js index c9f45d333886d3..7cce07ddc5d410 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -99,6 +99,8 @@ const { inspect: utilInspect, } = require('internal/util/inspect'); +const assert = require('internal/assert'); + const { codes: { ERR_BUFFER_OUT_OF_BOUNDS, @@ -1302,9 +1304,9 @@ function atob(input) { throw lazyDOMException( 'The string to be decoded is not correctly encoded.', 'InvalidCharacterError'); - case -3: // Possible overflow - // TODO(@anonrig): Throw correct error in here. - throw lazyDOMException('The input causes overflow.', 'InvalidCharacterError'); + case -3: + assert.fail('Unrecognized simdutf error'); + break; default: return result; } diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 0e4d437c1ea501..8dd88948cb827f 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1341,7 +1341,7 @@ static void Btoa(const FunctionCallbackInfo& args) { // In case of error, a negative value is returned: // * -1 indicates a single character remained, // * -2 indicates an invalid character, -// * -3 indicates a possible overflow (i.e., more than 2 GB output). +// * -3 indicates an unrecognized simdutf error. static void Atob(const FunctionCallbackInfo& args) { CHECK_EQ(args.Length(), 1); Environment* env = Environment::GetCurrent(args); @@ -1386,7 +1386,7 @@ static void Atob(const FunctionCallbackInfo& args) { return args.GetReturnValue().Set(value); } - // Default value is: "possible overflow" + // Default value is: "unrecognized simdutf error" int32_t error_code = -3; if (result.error == simdutf::error_code::INVALID_BASE64_CHARACTER) {