mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
feat(bake): handle bundle errors, re-assemble full client payloads, initial error modal (#14504)
This commit is contained in:
@@ -1520,7 +1520,7 @@ pub fn dumpStackTrace(trace: std.builtin.StackTrace) void {
|
||||
.action = .view_trace,
|
||||
.reason = .{ .zig_error = error.DumpStackTrace },
|
||||
.trace = &trace,
|
||||
}});
|
||||
}}) catch {};
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1601,6 +1601,49 @@ pub fn dumpStackTrace(trace: std.builtin.StackTrace) void {
|
||||
stderr.writeAll(proc.stderr) catch return;
|
||||
}
|
||||
|
||||
/// A variant of `std.builtin.StackTrace` that stores its data within itself
|
||||
/// instead of being a pointer. This allows storing captured stack traces
|
||||
/// for later printing.
|
||||
pub const StoredTrace = struct {
|
||||
data: [31]usize,
|
||||
index: usize,
|
||||
|
||||
pub const empty: StoredTrace = .{
|
||||
.data = .{0} ** 31,
|
||||
.index = 0,
|
||||
};
|
||||
|
||||
pub fn trace(stored: *StoredTrace) std.builtin.StackTrace {
|
||||
return .{
|
||||
.index = stored.index,
|
||||
.instruction_addresses = &stored.data,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn capture(begin: ?usize) StoredTrace {
|
||||
var stored: StoredTrace = StoredTrace.empty;
|
||||
var frame = stored.trace();
|
||||
std.debug.captureStackTrace(begin orelse @returnAddress(), &frame);
|
||||
stored.index = frame.index;
|
||||
return stored;
|
||||
}
|
||||
|
||||
pub fn from(stack_trace: ?*std.builtin.StackTrace) StoredTrace {
|
||||
if (stack_trace) |stack| {
|
||||
var data: [31]usize = undefined;
|
||||
@memset(&data, 0);
|
||||
const items = @min(stack.instruction_addresses.len, 31);
|
||||
@memcpy(data[0..items], stack.instruction_addresses[0..items]);
|
||||
return .{
|
||||
.data = data,
|
||||
.index = @min(items, stack.index),
|
||||
};
|
||||
} else {
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub const js_bindings = struct {
|
||||
const JSC = bun.JSC;
|
||||
const JSValue = JSC.JSValue;
|
||||
|
||||
Reference in New Issue
Block a user