mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
Merge branch 'main' into jarred/process-change
This commit is contained in:
@@ -97,12 +97,12 @@ pub const Version = struct {
|
||||
|
||||
const current_version: string = "bun-v" ++ Global.package_json_version;
|
||||
|
||||
pub export const Bun__githubURL: [*:0]const u8 = std.fmt.comptimePrint("https://github.com/oven-sh/bun/release/bun-v{s}/{s}", .{
|
||||
pub export const Bun__githubURL: [*:0]const u8 = std.fmt.comptimePrint("https://github.com/oven-sh/bun/releases/download/bun-v{s}/{s}", .{
|
||||
Global.package_json_version,
|
||||
zip_filename,
|
||||
});
|
||||
|
||||
pub const Bun__githubBaselineURL: [:0]const u8 = std.fmt.comptimePrint("https://github.com/oven-sh/bun/release/bun-v{s}/{s}", .{
|
||||
pub const Bun__githubBaselineURL: [:0]const u8 = std.fmt.comptimePrint("https://github.com/oven-sh/bun/releases/download/bun-v{s}/{s}", .{
|
||||
Global.package_json_version,
|
||||
baseline_zip_filename,
|
||||
});
|
||||
|
||||
Submodule src/deps/tinycc updated: ab631362d8...2d3ad9e0d3
11
src/fd.zig
11
src/fd.zig
@@ -302,7 +302,16 @@ pub const FDImpl = packed struct {
|
||||
return JSValue.jsNumberFromInt32(value.makeLibUVOwned().uv());
|
||||
}
|
||||
|
||||
pub fn format(this: FDImpl, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
pub fn format(this: FDImpl, comptime fmt: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
if (fmt.len == 1 and fmt[0] == 'd') {
|
||||
try writer.print("{d}", .{this.system()});
|
||||
return;
|
||||
}
|
||||
|
||||
if (fmt.len != 0) {
|
||||
@compileError("invalid format string for FDImpl.format. must be either '' or 'd'");
|
||||
}
|
||||
|
||||
if (!this.isValid()) {
|
||||
try writer.writeAll("[invalid_fd]");
|
||||
return;
|
||||
|
||||
@@ -163,11 +163,42 @@ const CppWebSocket = opaque {
|
||||
extern fn WebSocket__didReceiveText(websocket_context: *CppWebSocket, clone: bool, text: *const JSC.ZigString) void;
|
||||
extern fn WebSocket__didReceiveBytes(websocket_context: *CppWebSocket, bytes: [*]const u8, byte_len: usize, opcode: u8) void;
|
||||
extern fn WebSocket__rejectUnauthorized(websocket_context: *CppWebSocket) bool;
|
||||
pub const didConnect = WebSocket__didConnect;
|
||||
pub const didAbruptClose = WebSocket__didAbruptClose;
|
||||
pub const didClose = WebSocket__didClose;
|
||||
pub const didReceiveText = WebSocket__didReceiveText;
|
||||
pub const didReceiveBytes = WebSocket__didReceiveBytes;
|
||||
pub fn didAbruptClose(this: *CppWebSocket, reason: ErrorCode) void {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
WebSocket__didAbruptClose(this, reason);
|
||||
}
|
||||
pub fn didClose(this: *CppWebSocket, code: u16, reason: *const bun.String) void {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
WebSocket__didClose(this, code, reason);
|
||||
}
|
||||
pub fn didReceiveText(this: *CppWebSocket, clone: bool, text: *const JSC.ZigString) void {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
WebSocket__didReceiveText(this, clone, text);
|
||||
}
|
||||
pub fn didReceiveBytes(this: *CppWebSocket, bytes: [*]const u8, byte_len: usize, opcode: u8) void {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
WebSocket__didReceiveBytes(this, bytes, byte_len, opcode);
|
||||
}
|
||||
pub fn rejectUnauthorized(this: *CppWebSocket) bool {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
return WebSocket__rejectUnauthorized(this);
|
||||
}
|
||||
pub fn didConnect(this: *CppWebSocket, socket: *uws.Socket, buffered_data: ?[*]u8, buffered_len: usize) void {
|
||||
const loop = JSC.VirtualMachine.get().eventLoop();
|
||||
loop.enter();
|
||||
defer loop.exit();
|
||||
WebSocket__didConnect(this, socket, buffered_data, buffered_len);
|
||||
}
|
||||
extern fn WebSocket__incrementPendingActivity(websocket_context: *CppWebSocket) void;
|
||||
extern fn WebSocket__decrementPendingActivity(websocket_context: *CppWebSocket) void;
|
||||
pub fn ref(this: *CppWebSocket) void {
|
||||
@@ -175,11 +206,6 @@ const CppWebSocket = opaque {
|
||||
WebSocket__incrementPendingActivity(this);
|
||||
}
|
||||
|
||||
pub fn rejectUnauthorized(this: *CppWebSocket) bool {
|
||||
JSC.markBinding(@src());
|
||||
return WebSocket__rejectUnauthorized(this);
|
||||
}
|
||||
|
||||
pub fn unref(this: *CppWebSocket) void {
|
||||
JSC.markBinding(@src());
|
||||
WebSocket__decrementPendingActivity(this);
|
||||
@@ -344,6 +370,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type {
|
||||
|
||||
if (this.outgoing_websocket) |ws| {
|
||||
this.outgoing_websocket = null;
|
||||
|
||||
ws.didAbruptClose(ErrorCode.ended);
|
||||
}
|
||||
|
||||
@@ -409,11 +436,11 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type {
|
||||
|
||||
pub fn handleData(this: *HTTPClient, socket: Socket, data: []const u8) void {
|
||||
log("onData", .{});
|
||||
defer JSC.VirtualMachine.get().drainMicrotasks();
|
||||
if (this.outgoing_websocket == null) {
|
||||
this.clearData();
|
||||
return;
|
||||
}
|
||||
|
||||
std.debug.assert(socket.socket == this.tcp.?.socket);
|
||||
|
||||
if (comptime Environment.allow_assert)
|
||||
@@ -980,6 +1007,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type {
|
||||
if (this.outgoing_websocket) |ws| {
|
||||
this.outgoing_websocket = null;
|
||||
log("fail ({s})", .{@tagName(code)});
|
||||
|
||||
ws.didAbruptClose(code);
|
||||
}
|
||||
|
||||
@@ -1055,19 +1083,9 @@ pub fn NewWebSocketClient(comptime ssl: bool) type {
|
||||
this.clearData();
|
||||
return;
|
||||
};
|
||||
if (comptime Environment.isDebug) {
|
||||
this.event_loop.debug.enter();
|
||||
}
|
||||
defer {
|
||||
if (comptime Environment.isDebug) {
|
||||
this.event_loop.debug.enter();
|
||||
}
|
||||
}
|
||||
|
||||
switch (kind) {
|
||||
.Text => {
|
||||
defer this.event_loop.drainMicrotasks();
|
||||
|
||||
// this function encodes to UTF-16 if > 127
|
||||
// so we don't need to worry about latin1 non-ascii code points
|
||||
// we avoid trim since we wanna keep the utf8 validation intact
|
||||
@@ -1088,7 +1106,6 @@ pub fn NewWebSocketClient(comptime ssl: bool) type {
|
||||
}
|
||||
},
|
||||
.Binary, .Ping, .Pong => {
|
||||
defer this.event_loop.drainMicrotasks();
|
||||
JSC.markBinding(@src());
|
||||
out.didReceiveBytes(data_.ptr, data_.len, @as(u8, @intFromEnum(kind)));
|
||||
},
|
||||
@@ -1138,9 +1155,6 @@ pub fn NewWebSocketClient(comptime ssl: bool) type {
|
||||
// after receiving close we should ignore the data
|
||||
if (this.close_received) return;
|
||||
|
||||
// This is the start of a task, so we need to drain the microtask queue at the end
|
||||
defer JSC.VirtualMachine.get().drainMicrotasks();
|
||||
|
||||
// Due to scheduling, it is possible for the websocket onData
|
||||
// handler to run with additional data before the microtask queue is
|
||||
// drained.
|
||||
|
||||
@@ -333,7 +333,11 @@ describe("bun test", () => {
|
||||
});
|
||||
expect(stderr).toContain("Invalid timeout");
|
||||
});
|
||||
test("timeout can be set to 30ms", () => {
|
||||
// TODO: https://github.com/oven-sh/bun/issues/8069
|
||||
// This test crashes, which will pass because stderr contains "timed out"
|
||||
// but the crash can also mean it hangs, which will end up failing.
|
||||
// Possibly fixed by https://github.com/oven-sh/bun/pull/8076/files
|
||||
test.todo("timeout can be set to 30ms", () => {
|
||||
const stderr = runTest({
|
||||
args: ["--timeout", "30"],
|
||||
input: `
|
||||
|
||||
@@ -5,6 +5,7 @@ import { rmSync, chmodSync, mkdirSync, realpathSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { rmdirSync } from "js/node/fs/export-star-from";
|
||||
import { isIntelMacOS } from "../../../harness";
|
||||
|
||||
test("which", () => {
|
||||
{
|
||||
@@ -51,13 +52,16 @@ test("which", () => {
|
||||
}),
|
||||
).toBe(abs);
|
||||
|
||||
try {
|
||||
mkdirSync("myscript.sh");
|
||||
chmodSync("myscript.sh", "755");
|
||||
} catch (e) {}
|
||||
// TODO: only fails on x64 macos
|
||||
if (!isIntelMacOS) {
|
||||
try {
|
||||
mkdirSync("myscript.sh");
|
||||
chmodSync("myscript.sh", "755");
|
||||
} catch (e) {}
|
||||
|
||||
// directories should not be returned
|
||||
expect(which("myscript.sh")).toBe(null);
|
||||
// directories should not be returned
|
||||
expect(which("myscript.sh")).toBe(null);
|
||||
}
|
||||
|
||||
// "bun" is in our PATH
|
||||
expect(which("bun")!.length > 0).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user