Skip to content

Handle string max length correctly#6170

Merged
jasnell merged 1 commit intomainfrom
jasnell/handle-string-length
Feb 25, 2026
Merged

Handle string max length correctly#6170
jasnell merged 1 commit intomainfrom
jasnell/handle-string-length

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Feb 25, 2026

No description provided.

@jasnell jasnell requested a review from anonrig February 25, 2026 03:38
@jasnell jasnell requested review from a team as code owners February 25, 2026 03:38
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Feb 25, 2026

The fix is sound. The test works but is heavier than needed. However, the test is pragmatic — it clearly demonstrates the issue and the error message in the JSG_REQUIRE is clear. This is a defensive check that prevents a much worse outcome (V8 crash or undefined behavior).

Let me check if there are any other concerns — backward compatibility (this is a new error where none existed before):

The change introduces a new RangeError where previously V8 would have either crashed or thrown a less descriptive error. This is strictly an improvement — it makes an error case produce a clean, user-understandable error message. Since the previous behavior was an error/crash anyway (you can't create a V8 string larger than kMaxLength), this doesn't change any successful behavior. No compat flag needed.

LGTM

github run

@jasnell jasnell enabled auto-merge February 25, 2026 03:48
@jasnell jasnell merged commit 6fe776f into main Feb 25, 2026
37 of 38 checks passed
@jasnell jasnell deleted the jasnell/handle-string-length branch February 25, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants