Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: fix the rest of test-process #16026

Merged
merged 62 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9e0adfe
fix test-process-warning.js
nektro Dec 28, 2024
d12a3d2
stub out node:test
nektro Dec 28, 2024
9b25f5a
fix test-process-umask.js
nektro Dec 28, 2024
9d3fddf
fix test-process-umask-mask.js
nektro Dec 28, 2024
8f161ea
fix test-process-uid-gid.js
nektro Dec 28, 2024
295cbc0
fix test-process-title-cli.js
nektro Dec 28, 2024
13da098
don't lowercase Error instance printing
nektro Dec 28, 2024
0b1f020
fix test-process-setgroups.js
nektro Dec 28, 2024
e4bf5e5
fix test-process-release.js
nektro Dec 28, 2024
218c673
fix test-process-really-exit.js
nektro Dec 28, 2024
ca2a61e
fix
nektro Dec 28, 2024
2ebba0a
fix test-process-no-deprecation.js
nektro Dec 28, 2024
908287f
fix test-process-kill-pid.js
nektro Dec 28, 2024
24609c2
fix test-process-hrtime.js
nektro Dec 28, 2024
7f0adc1
tidy
nektro Dec 28, 2024
9227ca6
fix test-process-get-builtin.mjs
nektro Dec 31, 2024
e8e9e37
fix test-process-exit-code-validation.js
nektro Dec 31, 2024
1be1f0c
fix test-process-exception-capture-errors.js
nektro Dec 31, 2024
3f8a948
fix test-process-euid-egid.js
nektro Dec 31, 2024
c9fc1ed
fix test-process-emitwarning.js
nektro Dec 31, 2024
4d3d51e
fix test-process-dlopen-error-message-crash.js
nektro Dec 31, 2024
297091a
fix test-process-cpuUsage.js
nektro Dec 31, 2024
e7ab2d0
fix test-process-constrained-memory.js
nektro Dec 31, 2024
863c03e
fix test-process-config.js
nektro Dec 31, 2024
652e8d4
fix test-process-chdir.js
nektro Dec 31, 2024
0fa6ab4
add code missing from 24609c27cb
nektro Dec 31, 2024
5e834d1
zig: make FileSystem.top_level_dir nul-terminated
nektro Dec 31, 2024
6a51431
fix test-process-chdir-errormessage.js
nektro Dec 31, 2024
bee3360
fill in some errnoSys variants
nektro Jan 1, 2025
19febc6
fix test-process-binding-util.js
nektro Jan 1, 2025
2f66a40
fix test-process-beforeexit-throw-exit.js
nektro Jan 1, 2025
b84078f
fix test-process-available-memory.js
nektro Jan 1, 2025
fe3a953
make process constructor callable
nektro Jan 1, 2025
77ad70f
fix test-process-assert.js
nektro Jan 1, 2025
d098c67
fix test-child-process-stdio.js
nektro Jan 1, 2025
b2e5ac7
fix test-process-beforeexit.js
nektro Jan 1, 2025
4a93608
Merge remote-tracking branch 'origin/main' into nektro-patch-18634
nektro Jan 1, 2025
96c1339
fixes
nektro Jan 1, 2025
0a97612
lower flaky test retry count
nektro Jan 1, 2025
8da2df3
fixes
nektro Jan 1, 2025
cb1088e
fix
nektro Jan 2, 2025
9e3cd74
fix
nektro Jan 2, 2025
cc2730c
fix
nektro Jan 2, 2025
501794b
fix
nektro Jan 2, 2025
301bbd5
[skip ci] update docs
nektro Jan 3, 2025
a0c16bd
address review
nektro Jan 3, 2025
4113435
more startup time improvement
nektro Jan 3, 2025
b15a1b3
address review
nektro Jan 3, 2025
ae1b9f3
oops fix compile error
nektro Jan 3, 2025
e591cd1
unimplement process.getBuiltinModule
nektro Jan 3, 2025
be4552f
address review
nektro Jan 3, 2025
73efb0f
fixes
nektro Jan 3, 2025
7e72c75
fixes
nektro Jan 3, 2025
d9f2662
address review
nektro Jan 4, 2025
96e3185
Merge remote-tracking branch 'origin/main' into nektro-patch-18634
nektro Jan 4, 2025
c88d4c8
mutex guard process.title getter too
nektro Jan 4, 2025
456cb24
scripts/check-node-all.sh: sort files
nektro Jan 4, 2025
805ac81
tidy
nektro Jan 4, 2025
73bbc0c
undo this change
nektro Jan 4, 2025
a015057
fixes
nektro Jan 4, 2025
11500aa
Merge branch 'main' into nektro-patch-18634
nektro Jan 4, 2025
83ce207
fix
nektro Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/runtime/nodejs-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa

### [`process`](https://nodejs.org/api/process.html)

🟡 Missing `domain` `initgroups` `setegid` `seteuid` `setgid` `setgroups` `setuid` `allowedNodeEnvironmentFlags` `getActiveResourcesInfo` `setActiveResourcesInfo` `moduleLoadList` `setSourceMapsEnabled`. `process.binding` is partially implemented.
🟡 Missing `initgroups` `allowedNodeEnvironmentFlags` `getActiveResourcesInfo` `setActiveResourcesInfo` `moduleLoadList` `setSourceMapsEnabled`. `process.binding` is partially implemented.

### [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask)

Expand Down
2 changes: 1 addition & 1 deletion src/api/schema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ pub const Api = struct {
origin: ?[]const u8 = null,

/// absolute_working_dir
absolute_working_dir: ?[]const u8 = null,
absolute_working_dir: ?[:0]const u8 = null,

/// define
define: ?StringMap = null,
Expand Down
2 changes: 1 addition & 1 deletion src/bake/DevServer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const igLog = bun.Output.scoped(.IncrementalGraph, false);
pub const Options = struct {
/// Arena must live until DevServer.deinit()
arena: Allocator,
root: []const u8,
root: [:0]const u8,
vm: *VirtualMachine,
framework: bake.Framework,
bundler_options: bake.SplitBundlerOptions,
Expand Down
6 changes: 3 additions & 3 deletions src/bake/bake.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const UserOptions = struct {
arena: std.heap.ArenaAllocator,
allocations: StringRefList,

root: []const u8,
root: [:0]const u8,
framework: Framework,
bundler_options: SplitBundlerOptions,

Expand Down Expand Up @@ -78,9 +78,9 @@ pub const UserOptions = struct {
const StringRefList = struct {
strings: std.ArrayListUnmanaged(ZigString.Slice),

pub fn track(al: *StringRefList, str: ZigString.Slice) []const u8 {
pub fn track(al: *StringRefList, str: ZigString.Slice) [:0]const u8 {
al.strings.append(bun.default_allocator, str) catch bun.outOfMemory();
return str.slice();
return str.sliceZ();
}

pub fn free(al: *StringRefList) void {
Expand Down
704 changes: 496 additions & 208 deletions src/bun.js/bindings/BunProcess.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/bun.js/bindings/BunProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Process : public WebCore::JSEventEmitter {
}

DECLARE_EXPORT_INFO;
bool m_reportOnUncaughtException;
nektro marked this conversation as resolved.
Show resolved Hide resolved

static void destroy(JSC::JSCell* cell)
{
Expand Down
148 changes: 97 additions & 51 deletions src/bun.js/bindings/ErrorCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ WTF::String JSValueToStringSafe(JSC::JSGlobalObject* globalObject, JSValue arg)
return makeString("[Function: "_s, name, ']');
}

return "[Function: (anonymous)]"_s;
return "[Function (anonymous)]"_s;
break;
}

Expand Down Expand Up @@ -279,7 +279,7 @@ WTF::String determineSpecificType(JSC::JSGlobalObject* globalObject, JSValue val
if (!name.isNull() && name.length() > 0) {
return makeString("function "_s, name);
}
return String("function"_s);
return String("function "_s);
}
if (cell->isString()) {
auto str = value.toString(globalObject)->getString(globalObject);
Expand Down Expand Up @@ -405,7 +405,7 @@ namespace ERR {

JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name, const WTF::String& expected_type, JSC::JSValue val_actual_value)
{
auto arg_kind = arg_name.startsWith("options."_s) ? "property"_s : "argument"_s;
auto arg_kind = arg_name.contains('.') ? "property"_s : "argument"_s;
auto ty_first_char = expected_type[0];
auto ty_kind = ty_first_char >= 'A' && ty_first_char <= 'Z' ? "an instance of"_s : "of type"_s;

Expand All @@ -420,7 +420,7 @@ JSC::EncodedJSValue INVALID_ARG_TYPE(JSC::ThrowScope& throwScope, JSC::JSGlobalO
{
auto arg_name = val_arg_name.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
auto arg_kind = arg_name.startsWith("options."_s) ? "property"_s : "argument"_s;
auto arg_kind = arg_name.contains('.') ? "property"_s : "argument"_s;

auto ty_first_char = expected_type[0];
auto ty_kind = ty_first_char >= 'A' && ty_first_char <= 'Z' ? "an instance of"_s : "of type"_s;
Expand Down Expand Up @@ -500,7 +500,7 @@ JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObjec

JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason)
{
ASCIILiteral type = String(name).find('.') != notFound ? "property"_s : "argument"_s;
ASCIILiteral type = String(name).contains('.') ? "property"_s : "argument"_s;

auto value_string = JSValueToStringSafe(globalObject, value);
RETURN_IF_EXCEPTION(throwScope, {});
Expand All @@ -509,6 +509,20 @@ JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobal
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_INVALID_ARG_VALUE, message));
return {};
}
JSC::EncodedJSValue INVALID_ARG_VALUE_RangeError(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason)
{
ASCIILiteral type = String(name).contains('.') ? "property"_s : "argument"_s;

auto value_string = JSValueToStringSafe(globalObject, value);
RETURN_IF_EXCEPTION(throwScope, {});

auto& vm = globalObject->vm();
auto message = makeString("The "_s, type, " '"_s, name, "' "_s, reason, ". Received "_s, value_string);
auto* structure = createErrorStructure(vm, globalObject, ErrorType::RangeError, "RangeError"_s, "ERR_INVALID_ARG_VALUE"_s);
auto error = JSC::ErrorInstance::create(vm, structure, message, jsUndefined(), nullptr, JSC::RuntimeType::TypeNothing, ErrorType::RangeError, true);
throwScope.throwException(globalObject, error);
return {};
}
JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue name, JSC::JSValue value, const WTF::String& reason)
{
auto name_string = JSValueToStringSafe(globalObject, name);
Expand Down Expand Up @@ -551,7 +565,7 @@ JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlo

JSC::EncodedJSValue UNKNOWN_SIGNAL(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue signal, bool triedUppercase)
{
auto signal_string = JSValueToStringSafe(globalObject, signal);
auto signal_string = signal.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});

auto message_extra = triedUppercase ? " (signals must use all capital letters)"_s : ""_s;
Expand All @@ -574,6 +588,28 @@ JSC::EncodedJSValue SOCKET_BAD_PORT(JSC::ThrowScope& throwScope, JSC::JSGlobalOb
return {};
}

JSC::EncodedJSValue UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject)
{
auto message = makeString("`process.setupUncaughtExceptionCapture()` was called while a capture callback was already active"_s);
nektro marked this conversation as resolved.
Show resolved Hide resolved
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET, message));
return {};
}

JSC::EncodedJSValue ASSERTION(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue msg)
nektro marked this conversation as resolved.
Show resolved Hide resolved
{
auto msg_string = msg.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, {});
auto message = msg_string;
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_ASSERTION, message));
return {};
}
JSC::EncodedJSValue ASSERTION(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, ASCIILiteral msg)
{
auto message = msg;
throwScope.throwException(globalObject, createError(globalObject, ErrorCode::ERR_ASSERTION, message));
return {};
}

}

static JSC::JSValue ERR_INVALID_ARG_TYPE(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, JSValue arg0, JSValue arg1, JSValue arg2)
Expand All @@ -596,6 +632,25 @@ static JSC::JSValue ERR_INVALID_ARG_TYPE(JSC::ThrowScope& scope, JSC::JSGlobalOb
return createError(globalObject, ErrorCode::ERR_INVALID_ARG_TYPE, msg);
}

static JSValue ERR_INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue name, JSC::JSValue value, JSC::JSValue reason)
{
ASSERT(name.isString());
auto name_string = name.toWTFString(globalObject);
ASCIILiteral type = name_string.contains('.') ? "property"_s : "argument"_s;

auto value_string = JSValueToStringSafe(globalObject, value);
RETURN_IF_EXCEPTION(throwScope, {});

ASSERT(reason.isUndefined() || reason.isString());
if (reason.isUndefined()) {
auto message = makeString("The "_s, type, " '"_s, name_string, "' is invalid. Received "_s, value_string);
return createError(globalObject, ErrorCode::ERR_INVALID_ARG_VALUE, message);
}
auto reason_string = reason.toWTFString(globalObject);
auto message = makeString("The "_s, type, " '"_s, name_string, "' "_s, reason_string, ". Received "_s, value_string);
return createError(globalObject, ErrorCode::ERR_INVALID_ARG_VALUE, message);
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_OUT_OF_RANGE, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
JSC::VM& vm = globalObject->vm();
Expand All @@ -608,31 +663,11 @@ JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_OUT_OF_RANGE, (JSC::JSGlobalObject * glo
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_OUT_OF_RANGE, message));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_IPC_DISCONNECTED, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_DISCONNECTED, "IPC channel is already disconnected"_s));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_SERVER_NOT_RUNNING, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SERVER_NOT_RUNNING, "Server is not running."_s));
}

extern "C" JSC::EncodedJSValue Bun__createErrorWithCode(JSC::JSGlobalObject* globalObject, ErrorCode code, BunString* message)
{
return JSValue::encode(createError(globalObject, code, message->toWTFString(BunString::ZeroCopy)));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_IPC_CHANNEL_CLOSED, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_CHANNEL_CLOSED, "Channel closed."_s));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_SOCKET_BAD_TYPE, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_BAD_TYPE, "Bad socket type specified. Valid types are: udp4, udp6"_s));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_INVALID_PROTOCOL, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
JSC::VM& vm = globalObject->vm();
Expand All @@ -650,19 +685,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_INVALID_PROTOCOL, (JSC::JSGlobalObject *
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_INVALID_PROTOCOL, message));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_INVALID_ARG_TYPE, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
JSC::VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);

EXPECT_ARG_COUNT(3);

auto arg_name = callFrame->argument(0);
auto expected_type = callFrame->argument(1);
auto actual_value = callFrame->argument(2);
return JSValue::encode(ERR_INVALID_ARG_TYPE(scope, globalObject, arg_name, expected_type, actual_value));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_BROTLI_INVALID_PARAM, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
JSC::VM& vm = globalObject->vm();
Expand Down Expand Up @@ -691,16 +713,6 @@ JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_BUFFER_TOO_LARGE, (JSC::JSGlobalObject *
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_BUFFER_TOO_LARGE, message));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_ZLIB_INITIALIZATION_FAILED, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_ZLIB_INITIALIZATION_FAILED, "Initialization failed"_s));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_BUFFER_OUT_OF_BOUNDS, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
{
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS, "Attempt to access memory outside buffer bounds"_s));
}

JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_UNHANDLED_ERROR, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
JSC::VM& vm = globalObject->vm();
Expand Down Expand Up @@ -780,7 +792,7 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
JSC::VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);

EXPECT_ARG_COUNT(2);
EXPECT_ARG_COUNT(1);

JSC::JSValue codeValue = callFrame->argument(0);
RETURN_IF_EXCEPTION(scope, {});
Expand Down Expand Up @@ -808,9 +820,43 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
JSValue arg0 = callFrame->argument(1);
JSValue arg1 = callFrame->argument(2);
JSValue arg2 = callFrame->argument(3);

return JSValue::encode(ERR_INVALID_ARG_TYPE(scope, globalObject, arg0, arg1, arg2));
}

case Bun::ErrorCode::ERR_INVALID_ARG_VALUE: {
JSValue arg0 = callFrame->argument(1);
JSValue arg1 = callFrame->argument(2);
JSValue arg2 = callFrame->argument(3);
return JSValue::encode(ERR_INVALID_ARG_VALUE(scope, globalObject, arg0, arg1, arg2));
}

case ErrorCode::ERR_IPC_DISCONNECTED:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_DISCONNECTED, "IPC channel is already disconnected"_s));
case ErrorCode::ERR_SERVER_NOT_RUNNING:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SERVER_NOT_RUNNING, "Server is not running."_s));
case ErrorCode::ERR_IPC_CHANNEL_CLOSED:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_CHANNEL_CLOSED, "Channel closed."_s));
case ErrorCode::ERR_SOCKET_BAD_TYPE:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_BAD_TYPE, "Bad socket type specified. Valid types are: udp4, udp6"_s));
case ErrorCode::ERR_ZLIB_INITIALIZATION_FAILED:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_ZLIB_INITIALIZATION_FAILED, "Initialization failed"_s));
case ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_BUFFER_OUT_OF_BOUNDS, "Attempt to access memory outside buffer bounds"_s));
case ErrorCode::ERR_IPC_ONE_PIPE:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_IPC_ONE_PIPE, "Child process can have only one IPC pipe"_s));
case ErrorCode::ERR_SOCKET_ALREADY_BOUND:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_ALREADY_BOUND, "Socket is already bound"_s));
case ErrorCode::ERR_SOCKET_BAD_BUFFER_SIZE:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_BAD_BUFFER_SIZE, "Buffer size must be a positive integer"_s));
case ErrorCode::ERR_SOCKET_DGRAM_IS_CONNECTED:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_DGRAM_IS_CONNECTED, "Already connected"_s));
case ErrorCode::ERR_SOCKET_DGRAM_NOT_CONNECTED:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_DGRAM_NOT_CONNECTED, "Not connected"_s));
case ErrorCode::ERR_SOCKET_DGRAM_NOT_RUNNING:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_SOCKET_DGRAM_NOT_RUNNING, "Not running"_s));
case ErrorCode::ERR_INVALID_CURSOR_POS:
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_INVALID_CURSOR_POS, "Cannot set cursor row without setting its column"_s));

default: {
break;
}
Expand Down
11 changes: 4 additions & 7 deletions src/bun.js/bindings/ErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,11 @@ JSC::JSValue toJS(JSC::JSGlobalObject*, ErrorCode);
JSObject* createInvalidThisError(JSGlobalObject* globalObject, JSValue thisValue, const ASCIILiteral typeName);
JSObject* createInvalidThisError(JSGlobalObject* globalObject, const String& message);

JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_INVALID_ARG_TYPE);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_OUT_OF_RANGE);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_IPC_DISCONNECTED);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_SERVER_NOT_RUNNING);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_IPC_CHANNEL_CLOSED);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_SOCKET_BAD_TYPE);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_INVALID_PROTOCOL);
JSC_DECLARE_HOST_FUNCTION(jsFunctionMakeErrorWithCode);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_BROTLI_INVALID_PARAM);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_BUFFER_TOO_LARGE);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_ZLIB_INITIALIZATION_FAILED);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_BUFFER_OUT_OF_BOUNDS);
JSC_DECLARE_HOST_FUNCTION(jsFunction_ERR_UNHANDLED_ERROR);

enum Bound {
Expand All @@ -84,13 +77,17 @@ JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObjec
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue arg_name_val, const WTF::String& msg, JSC::JSValue actual);
JSC::EncodedJSValue OUT_OF_RANGE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& arg_name_val, const WTF::String& msg, JSC::JSValue actual);
JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason = "is invalid"_s);
JSC::EncodedJSValue INVALID_ARG_VALUE_RangeError(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, WTF::ASCIILiteral name, JSC::JSValue value, const WTF::String& reason = "is invalid"_s);
JSC::EncodedJSValue INVALID_ARG_VALUE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue name, JSC::JSValue value, const WTF::String& reason = "is invalid"_s);
JSC::EncodedJSValue UNKNOWN_ENCODING(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::StringView encoding);
JSC::EncodedJSValue INVALID_STATE(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, const WTF::String& statemsg);
JSC::EncodedJSValue STRING_TOO_LONG(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
JSC::EncodedJSValue BUFFER_OUT_OF_BOUNDS(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
JSC::EncodedJSValue UNKNOWN_SIGNAL(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue signal, bool triedUppercase = false);
JSC::EncodedJSValue SOCKET_BAD_PORT(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue name, JSC::JSValue port, bool allowZero);
JSC::EncodedJSValue UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject);
JSC::EncodedJSValue ASSERTION(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, JSC::JSValue msg);
JSC::EncodedJSValue ASSERTION(JSC::ThrowScope& throwScope, JSC::JSGlobalObject* globalObject, ASCIILiteral msg);

}

Expand Down
11 changes: 11 additions & 0 deletions src/bun.js/bindings/ErrorCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ export default [
["ERR_SCRIPT_EXECUTION_TIMEOUT", Error, "Error"],
["ERR_SCRIPT_EXECUTION_INTERRUPTED", Error, "Error"],
["ERR_UNHANDLED_ERROR", Error],
["ERR_UNKNOWN_CREDENTIAL", Error],
["ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET", Error],
["ERR_DLOPEN_FAILED", Error],
["ERR_ASSERTION", Error],
["ERR_IPC_ONE_PIPE", Error],
["ERR_SOCKET_ALREADY_BOUND", Error],
["ERR_SOCKET_BAD_BUFFER_SIZE", TypeError],
["ERR_SOCKET_DGRAM_IS_CONNECTED", Error],
["ERR_SOCKET_DGRAM_NOT_CONNECTED", Error],
["ERR_SOCKET_DGRAM_NOT_RUNNING", Error],
["ERR_INVALID_CURSOR_POS", TypeError],

// Bun-specific
["ERR_FORMDATA_PARSE_ERROR", TypeError],
Expand Down
Loading
Loading