Skip to main content

MAX_STRING_LENGTH

Constant MAX_STRING_LENGTH 

Source
pub const MAX_STRING_LENGTH: usize = 536_870_888;
Expand description

V8’s String::kMaxLength on a 64-bit build, in UTF-16 code units — the largest string the engine will materialize.

Measured on node v26.7.0 (darwin arm64): require('buffer').constants.MAX_STRING_LENGTH is 536870888, 'a'.repeat(536870888) succeeds with that length, and 'a'.repeat(536870889) is RangeError: Invalid string length.