mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 22:01:47 +00:00
Merge branch 'main' of github.com:oven-sh/bun into ali/fix-tls-error-servername
This commit is contained in:
@@ -331,16 +331,14 @@ function getZigAgent(platform, options) {
|
||||
return getEc2Agent(
|
||||
{
|
||||
os: "linux",
|
||||
arch: "x64",
|
||||
arch: "aarch64",
|
||||
abi: "musl",
|
||||
distro: "alpine",
|
||||
release: "3.21",
|
||||
},
|
||||
options,
|
||||
{
|
||||
instanceType: "c7i.2xlarge",
|
||||
cpuCount: 4,
|
||||
threadsPerCore: 1,
|
||||
instanceType: "r8g.large",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
18
.github/CODEOWNERS
vendored
18
.github/CODEOWNERS
vendored
@@ -1,18 +1,18 @@
|
||||
# Project
|
||||
.github/CODEOWNERS @Jarred-Sumner
|
||||
/.github/CODEOWNERS @Jarred-Sumner
|
||||
|
||||
# Build system
|
||||
CMakeLists.txt @Electroid
|
||||
cmake/ @Electroid
|
||||
scripts/ @Electroid
|
||||
/CMakeLists.txt @Electroid
|
||||
/cmake/*.cmake @Electroid
|
||||
/scripts/ @Electroid
|
||||
|
||||
# CI
|
||||
.buildkite/ @Electroid
|
||||
.github/workflows/ @Electroid
|
||||
/.buildkite/ @Electroid
|
||||
/.github/workflows/ @Electroid
|
||||
|
||||
# Debugger protocol
|
||||
packages/bun-inspector-protocol/ @Electroid
|
||||
packages/bun-debug-adapter-protocol/ @Electroid
|
||||
/packages/bun-inspector-protocol/ @Electroid
|
||||
/packages/bun-debug-adapter-protocol/ @Electroid
|
||||
|
||||
# Tests
|
||||
test/expectations.txt @Jarred-Sumner
|
||||
/test/expectations.txt @Jarred-Sumner
|
||||
|
||||
@@ -8,5 +8,4 @@ packages/bun-usockets/src/quic.c
|
||||
packages/bun-usockets/src/socket.c
|
||||
packages/bun-usockets/src/udp.c
|
||||
src/bun.js/bindings/uv-posix-polyfills.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
src/asan-config.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
@@ -222,6 +222,7 @@ src/bun.js/webcore/Response.zig
|
||||
src/bun.js/webcore/S3Client.zig
|
||||
src/bun.js/webcore/S3File.zig
|
||||
src/bun.js/webcore/S3Stat.zig
|
||||
src/bun.js/webcore/ScriptExecutionContext.zig
|
||||
src/bun.js/webcore/Sink.zig
|
||||
src/bun.js/webcore/streams.zig
|
||||
src/bun.js/webcore/TextDecoder.zig
|
||||
@@ -46,7 +46,7 @@ endif()
|
||||
|
||||
set(BUN_ERROR_SOURCE ${CWD}/packages/bun-error)
|
||||
|
||||
absolute_sources(BUN_ERROR_SOURCES ${CWD}/cmake/BunErrorSources.txt)
|
||||
absolute_sources(BUN_ERROR_SOURCES ${CWD}/cmake/sources/BunErrorSources.txt)
|
||||
|
||||
set(BUN_ERROR_OUTPUT ${CODEGEN_PATH}/bun-error)
|
||||
set(BUN_ERROR_OUTPUTS
|
||||
@@ -135,7 +135,7 @@ register_command(
|
||||
|
||||
set(BUN_NODE_FALLBACKS_SOURCE ${CWD}/src/node-fallbacks)
|
||||
|
||||
absolute_sources(BUN_NODE_FALLBACKS_SOURCES ${CWD}/cmake/NodeFallbacksSources.txt)
|
||||
absolute_sources(BUN_NODE_FALLBACKS_SOURCES ${CWD}/cmake/sources/NodeFallbacksSources.txt)
|
||||
|
||||
set(BUN_NODE_FALLBACKS_OUTPUT ${CODEGEN_PATH}/node-fallbacks)
|
||||
set(BUN_NODE_FALLBACKS_OUTPUTS)
|
||||
@@ -235,7 +235,7 @@ register_command(
|
||||
|
||||
set(BUN_ZIG_GENERATED_CLASSES_SCRIPT ${CWD}/src/codegen/generate-classes.ts)
|
||||
|
||||
absolute_sources(BUN_ZIG_GENERATED_CLASSES_SOURCES ${CWD}/cmake/ZigGeneratedClassesSources.txt)
|
||||
absolute_sources(BUN_ZIG_GENERATED_CLASSES_SOURCES ${CWD}/cmake/sources/ZigGeneratedClassesSources.txt)
|
||||
|
||||
set(BUN_ZIG_GENERATED_CLASSES_OUTPUTS
|
||||
${CODEGEN_PATH}/ZigGeneratedClasses.h
|
||||
@@ -268,8 +268,8 @@ register_command(
|
||||
|
||||
set(BUN_JAVASCRIPT_CODEGEN_SCRIPT ${CWD}/src/codegen/bundle-modules.ts)
|
||||
|
||||
absolute_sources(BUN_JAVASCRIPT_SOURCES ${CWD}/cmake/JavaScriptSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_CODEGEN_SOURCES ${CWD}/cmake/JavaScriptCodegenSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_SOURCES ${CWD}/cmake/sources/JavaScriptSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_CODEGEN_SOURCES ${CWD}/cmake/sources/JavaScriptCodegenSources.txt)
|
||||
|
||||
list(APPEND BUN_JAVASCRIPT_CODEGEN_SOURCES
|
||||
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
|
||||
@@ -311,7 +311,7 @@ register_command(
|
||||
|
||||
set(BUN_BAKE_RUNTIME_CODEGEN_SCRIPT ${CWD}/src/codegen/bake-codegen.ts)
|
||||
|
||||
absolute_sources(BUN_BAKE_RUNTIME_SOURCES ${CWD}/cmake/BakeRuntimeSources.txt)
|
||||
absolute_sources(BUN_BAKE_RUNTIME_SOURCES ${CWD}/cmake/sources/BakeRuntimeSources.txt)
|
||||
|
||||
list(APPEND BUN_BAKE_RUNTIME_CODEGEN_SOURCES
|
||||
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
|
||||
@@ -344,7 +344,7 @@ register_command(
|
||||
|
||||
set(BUN_BINDGEN_SCRIPT ${CWD}/src/codegen/bindgen.ts)
|
||||
|
||||
absolute_sources(BUN_BINDGEN_SOURCES ${CWD}/cmake/BindgenSources.txt)
|
||||
absolute_sources(BUN_BINDGEN_SOURCES ${CWD}/cmake/sources/BindgenSources.txt)
|
||||
|
||||
set(BUN_BINDGEN_CPP_OUTPUTS
|
||||
${CODEGEN_PATH}/GeneratedBindings.cpp
|
||||
@@ -501,7 +501,7 @@ WEBKIT_ADD_SOURCE_DEPENDENCIES(
|
||||
|
||||
# --- Zig ---
|
||||
|
||||
absolute_sources(BUN_ZIG_SOURCES ${CWD}/cmake/ZigSources.txt)
|
||||
absolute_sources(BUN_ZIG_SOURCES ${CWD}/cmake/sources/ZigSources.txt)
|
||||
|
||||
list(APPEND BUN_ZIG_SOURCES
|
||||
${CWD}/build.zig
|
||||
@@ -598,8 +598,8 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "build.zig")
|
||||
set(BUN_USOCKETS_SOURCE ${CWD}/packages/bun-usockets)
|
||||
|
||||
# hand written cpp source files. Full list of "source" code (including codegen) is in BUN_CPP_SOURCES
|
||||
absolute_sources(BUN_CXX_SOURCES ${CWD}/cmake/CxxSources.txt)
|
||||
absolute_sources(BUN_C_SOURCES ${CWD}/cmake/CSources.txt)
|
||||
absolute_sources(BUN_CXX_SOURCES ${CWD}/cmake/sources/CxxSources.txt)
|
||||
absolute_sources(BUN_C_SOURCES ${CWD}/cmake/sources/CSources.txt)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle.cpp)
|
||||
|
||||
@@ -42,11 +42,11 @@ export default class RuntimeError {
|
||||
original: Error;
|
||||
stack: StackFrame[];
|
||||
|
||||
static from(error: Error) {
|
||||
static from(error: Error): RuntimeError {
|
||||
const runtime = new RuntimeError();
|
||||
runtime.original = error;
|
||||
runtime.stack = this.parseStack(error);
|
||||
return RuntimeError;
|
||||
return runtime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ async function globSources(output, patterns, excludes = []) {
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.join("\n");
|
||||
|
||||
await write(join(root, "cmake", output), sources);
|
||||
await write(join(root, "cmake", "sources", output), sources);
|
||||
}
|
||||
|
||||
const input = await file(join(root, "cmake", "Sources.json")).json();
|
||||
|
||||
@@ -280,46 +280,40 @@ fn decodeSlice(this: *TextDecoder, globalThis: *JSC.JSGlobalObject, buffer_slice
|
||||
}
|
||||
|
||||
pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!*TextDecoder {
|
||||
var args_ = callframe.arguments_old(2);
|
||||
var arguments: []const JSC.JSValue = args_.ptr[0..args_.len];
|
||||
const encoding_value, const options_value = callframe.argumentsAsArray(2);
|
||||
|
||||
var decoder = TextDecoder{};
|
||||
|
||||
if (arguments.len > 0) {
|
||||
// encoding
|
||||
if (arguments[0].isString()) {
|
||||
var str = try arguments[0].toSlice(globalThis, bun.default_allocator);
|
||||
defer if (str.isAllocated()) str.deinit();
|
||||
if (encoding_value.isString()) {
|
||||
var str = try encoding_value.toSlice(globalThis, bun.default_allocator);
|
||||
defer str.deinit();
|
||||
|
||||
if (EncodingLabel.which(str.slice())) |label| {
|
||||
decoder.encoding = label;
|
||||
} else {
|
||||
return globalThis.ERR(.ENCODING_NOT_SUPPORTED, "Unsupported encoding label \"{s}\"", .{str.slice()}).throw();
|
||||
}
|
||||
} else if (arguments[0].isUndefined()) {
|
||||
// default to utf-8
|
||||
decoder.encoding = EncodingLabel.@"UTF-8";
|
||||
if (EncodingLabel.which(str.slice())) |label| {
|
||||
decoder.encoding = label;
|
||||
} else {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(encoding) label is invalid", .{});
|
||||
return globalThis.ERR(.ENCODING_NOT_SUPPORTED, "Unsupported encoding label \"{s}\"", .{str.slice()}).throw();
|
||||
}
|
||||
} else if (encoding_value.isUndefined()) {
|
||||
// default to utf-8
|
||||
decoder.encoding = EncodingLabel.@"UTF-8";
|
||||
} else {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(encoding) label is invalid", .{});
|
||||
}
|
||||
|
||||
if (!options_value.isUndefined()) {
|
||||
if (!options_value.isObject()) {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(options) is invalid", .{});
|
||||
}
|
||||
|
||||
if (arguments.len >= 2) {
|
||||
const options = arguments[1];
|
||||
if (try options_value.get(globalThis, "fatal")) |fatal| {
|
||||
decoder.fatal = fatal.toBoolean();
|
||||
}
|
||||
|
||||
if (!options.isObject()) {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(options) is invalid", .{});
|
||||
}
|
||||
|
||||
if (try options.get(globalThis, "fatal")) |fatal| {
|
||||
decoder.fatal = fatal.toBoolean();
|
||||
}
|
||||
|
||||
if (try options.get(globalThis, "ignoreBOM")) |ignoreBOM| {
|
||||
if (ignoreBOM.isBoolean()) {
|
||||
decoder.ignore_bom = ignoreBOM.asBoolean();
|
||||
} else {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(options) ignoreBOM is invalid. Expected boolean value", .{});
|
||||
}
|
||||
if (try options_value.get(globalThis, "ignoreBOM")) |ignoreBOM| {
|
||||
if (ignoreBOM.isBoolean()) {
|
||||
decoder.ignore_bom = ignoreBOM.asBoolean();
|
||||
} else {
|
||||
return globalThis.throwInvalidArguments("TextDecoder(options) ignoreBOM is invalid. Expected boolean value", .{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ const words: Record<string, { reason: string; limit?: number; regex?: boolean }>
|
||||
"std.fs.File": { reason: "Prefer bun.sys + bun.FD instead of std.fs", limit: 64 },
|
||||
".stdFile()": { reason: "Prefer bun.sys + bun.FD instead of std.fs.File. Zig hides 'errno' when Bun wants to match libuv", limit: 18 },
|
||||
".stdDir()": { reason: "Prefer bun.sys + bun.FD instead of std.fs.File. Zig hides 'errno' when Bun wants to match libuv", limit: 48 },
|
||||
".arguments_old(": { reason: "Please migrate to .argumentsAsArray() or another argument API", limit: 286 },
|
||||
".arguments_old(": { reason: "Please migrate to .argumentsAsArray() or another argument API", limit: 285 },
|
||||
"// autofix": { reason: "Evaluate if this variable should be deleted entirely or explicitly discarded.", limit: 176 },
|
||||
};
|
||||
const words_keys = [...Object.keys(words)];
|
||||
|
||||
9
test/js/bun/runtime-error.test.ts
Normal file
9
test/js/bun/runtime-error.test.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import RuntimeError from "../../../packages/bun-error/runtime-error";
|
||||
|
||||
test("RuntimeError.from returns instance", () => {
|
||||
const err = new Error("boom");
|
||||
const runtime = RuntimeError.from(err);
|
||||
expect(runtime.original).toBe(err);
|
||||
expect(Array.isArray(runtime.stack)).toBe(true);
|
||||
});
|
||||
@@ -298,6 +298,12 @@ describe("TextDecoder", () => {
|
||||
const decoder = new TextDecoder(undefined);
|
||||
expect(decoder.encoding).toBe("utf-8");
|
||||
});
|
||||
|
||||
it("should support undefined options", () => {
|
||||
expect(() => {
|
||||
const decoder = new TextDecoder("utf-8", undefined);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe("TextDecoder ignoreBOM", () => {
|
||||
|
||||
Reference in New Issue
Block a user