mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 06:41:50 +00:00
fix(bindings): handle errors from String.toJS() for oversized strings (#26213)
## Summary - When a string exceeds `WTF::String::MaxLength` (~4GB), `bun.String.createUninitialized()` returns a `.Dead` tag - The C++ layer now properly throws `ERR_STRING_TOO_LONG` when this happens - Updated `String.toJS()` in Zig to return `bun.JSError!jsc.JSValue` instead of just `jsc.JSValue` - Updated ~40 Zig caller files to handle the error with `try` - C++ callers updated with `RETURN_IF_EXCEPTION` checks ## Test plan - [x] `bun bd test test/js/node/buffer.test.js` - 449 tests pass - [x] `bun bd test/js/node/test/parallel/test-buffer-tostring-rangeerror.js` - passes 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude Bot <claude-bot@bun.sh>
This commit is contained in:
@@ -428,7 +428,7 @@ pub fn onHandshake(this: *PostgresSQLConnection, success: i32, ssl_error: uws.us
|
||||
|
||||
.verify_ca, .verify_full => {
|
||||
if (ssl_error.error_no != 0) {
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject));
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject) catch return);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ pub fn onHandshake(this: *PostgresSQLConnection, success: i32, ssl_error: uws.us
|
||||
if (BoringSSL.c.SSL_get_servername(ssl_ptr, 0)) |servername| {
|
||||
const hostname = servername[0..bun.len(servername)];
|
||||
if (!BoringSSL.checkServerIdentity(ssl_ptr, hostname)) {
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject));
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject) catch return);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -447,7 +447,7 @@ pub fn onHandshake(this: *PostgresSQLConnection, success: i32, ssl_error: uws.us
|
||||
} else {
|
||||
// if we are here is because server rejected us, and the error_no is the cause of this
|
||||
// no matter if reject_unauthorized is false because we are disconnected by the server
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject));
|
||||
this.failWithJSValue(ssl_error.toJS(this.globalObject) catch return);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user