Repository navigation
RangeError: Invalid string length when logging a particular Error with console.error #64136
Copy link
Copy link
Closed
Closed
Copy link
Description
Version
v26.3.1
Platform
Darwin HQX-VGM7H2WVFG 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:41:06 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6030 arm64 arm Darwin
Subsystem
util
What steps will reproduce the bug?
npm install @formatjs/icu-messageformat-parser@3.5.11.- Save this script:
try {
require('@formatjs/icu-messageformat-parser').parse(
`{0, plural, one {# ''אהבתי'''} two {# ''אהבתי'''} other {# ''אהבתי'''} }`,
{ requiresOtherClause: true, ignoreTag: true, shouldParseSkeletons: false },
);
} catch (err) {
console.error(err);
}- Run it. Observe error in the title:
λ node foo.js
node:internal/util/inspect:1885
tempLine += ctx.stylize(nodeModule, 'module');
^
RangeError: Invalid string length
at markNodeModules (node:internal/util/inspect:1885:21)
at formatError (node:internal/util/inspect:2019:18)
at formatRaw (node:internal/util/inspect:1362:14)
at formatValue (node:internal/util/inspect:1195:19)
at inspect (node:internal/util/inspect:409:10)
at formatWithOptionsInternal (node:internal/util/inspect:2917:40)
at formatWithOptions (node:internal/util/inspect:2779:10)
at console.value (node:internal/console/constructor:377:14)
at console.error (node:internal/console/constructor:444:61)
at Object.<anonymous> (/Users/ikerins/web/foo.js:7:11)
Node.js v26.3.1
I was not able to reduce the reproduction to not use the library, e.g. by manually constructing a SyntaxError with the same properties that it is producing:
https://github.com/formatjs/formatjs/blob/2093ca683a08dd8ae0226085329e9811eca38791/packages/icu-messageformat-parser/index.ts#L49-L56
I'm not sure why that doesn't work. Sorry.
How often does it reproduce? Is there a required condition?
Always reproduces with the above script. I could not narrow it down beyond that.
What is the expected behavior? Why is that the expected behavior?
console.error does not throw.
What do you see instead?
λ node foo.js
node:internal/util/inspect:1885
tempLine += ctx.stylize(nodeModule, 'module');
^
RangeError: Invalid string length
at markNodeModules (node:internal/util/inspect:1885:21)
at formatError (node:internal/util/inspect:2019:18)
at formatRaw (node:internal/util/inspect:1362:14)
at formatValue (node:internal/util/inspect:1195:19)
at inspect (node:internal/util/inspect:409:10)
at formatWithOptionsInternal (node:internal/util/inspect:2917:40)
at formatWithOptions (node:internal/util/inspect:2779:10)
at console.value (node:internal/console/constructor:377:14)
at console.error (node:internal/console/constructor:444:61)
at Object.<anonymous> (/Users/ikerins/web/foo.js:7:11)
Node.js v26.3.1
Additional information
The SyntaxError being logged looks like this, but just constructing one with these properties directly does not reproduce, for reasons unknown. This:
console.log(err.message);
console.log(err.stack);
console.log(err.location);
console.log(err.originalMessage);
Produces:
EXPECT_ARGUMENT_CLOSING_BRACE
SyntaxError: EXPECT_ARGUMENT_CLOSING_BRACE
at Module.parse (/Users/ikerins/web/node_modules/@formatjs/index.ts:50:19)
at Object.<anonymous> (/Users/ikerins/web/foo.js:2:49)
at Module._compile (node:internal/modules/cjs/loader:1873:14)
at Object..js (node:internal/modules/cjs/loader:2013:10)
at Module.load (node:internal/modules/cjs/loader:1596:32)
at Module._load (node:internal/modules/cjs/loader:1398:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47
{
start: { offset: 57, line: 1, column: 58 },
end: { offset: 73, line: 1, column: 74 }
}
{0, plural, one {# ''אהבתי'''} two {# ''אהבתי'''} other {# ''אהבתי'''} }
Also, the offending console.error invocation hangs for a pretty long time before throwing. About 5-7s.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
3zrv commentedon Jun 27, 2026
fixed here: #64022
isker commentedon Jun 27, 2026
Hah, thanks.