mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
fix error message in bun.serve (#8828)
* fix error message in bun.serve * ok
This commit is contained in:
@@ -861,28 +861,6 @@ pub const ServerConfig = struct {
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.getTruthy(global, "tls")) |tls| {
|
||||
if (SSLConfig.inJS(global, tls, exception)) |ssl_config| {
|
||||
args.ssl_config = ssl_config;
|
||||
}
|
||||
|
||||
if (exception.* != null) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
// @compatibility Bun v0.x - v0.2.1
|
||||
// this used to be top-level, now it's "tls" object
|
||||
if (args.ssl_config == null) {
|
||||
if (SSLConfig.inJS(global, arg, exception)) |ssl_config| {
|
||||
args.ssl_config = ssl_config;
|
||||
}
|
||||
|
||||
if (exception.* != null) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg.getTruthy(global, "maxRequestBodySize")) |max_request_body_size| {
|
||||
if (max_request_body_size.isNumber()) {
|
||||
args.max_request_body_size = @as(u64, @intCast(@max(0, max_request_body_size.toInt64())));
|
||||
@@ -917,6 +895,36 @@ pub const ServerConfig = struct {
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
if (arg.getTruthy(global, "tls")) |tls| {
|
||||
if (SSLConfig.inJS(global, tls, exception)) |ssl_config| {
|
||||
args.ssl_config = ssl_config;
|
||||
}
|
||||
|
||||
if (exception.* != null) {
|
||||
return args;
|
||||
}
|
||||
|
||||
if (global.hasException()) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
// @compatibility Bun v0.x - v0.2.1
|
||||
// this used to be top-level, now it's "tls" object
|
||||
if (args.ssl_config == null) {
|
||||
if (SSLConfig.inJS(global, arg, exception)) |ssl_config| {
|
||||
args.ssl_config = ssl_config;
|
||||
}
|
||||
|
||||
if (exception.* != null) {
|
||||
return args;
|
||||
}
|
||||
|
||||
if (global.hasException()) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JSC.throwInvalidArguments("Bun.serve expects an object", .{}, global, exception);
|
||||
return args;
|
||||
|
||||
@@ -5351,3 +5351,8 @@ extern "C" EncodedJSValue ExpectStatic__getPrototype(JSC::JSGlobalObject* global
|
||||
{
|
||||
return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)->JSExpectStaticPrototype());
|
||||
}
|
||||
|
||||
extern "C" bool JSGlobalObject__hasException(JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
return DECLARE_CATCH_SCOPE(globalObject->vm()).exception() != 0;
|
||||
}
|
||||
|
||||
@@ -2922,6 +2922,11 @@ pub const JSGlobalObject = extern struct {
|
||||
return cppFn("getCachedObject", .{ this, key });
|
||||
}
|
||||
|
||||
extern fn JSGlobalObject__hasException(*JSGlobalObject) bool;
|
||||
pub fn hasException(this: *JSGlobalObject) bool {
|
||||
return JSGlobalObject__hasException(this);
|
||||
}
|
||||
|
||||
pub fn vm(this: *JSGlobalObject) *VM {
|
||||
return cppFn("vm", .{this});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user