Add synthetic stack frame creation for BuildMessage/ResolveMessage

- Add BuildMessage__createSyntheticStackFrame export
- Add ResolveMessage__createSyntheticStackFrame export
- These create ZigStackFrame with correct file/line/column from location data
- Still need to wire up injection into ErrorInstance stack

WIP: Stack trace still showing bundler frames, needs synthetic frame injection
This commit is contained in:
Claude Bot
2025-10-06 02:08:27 +00:00
parent c888f9c3bb
commit 873acbc28e
2 changed files with 46 additions and 0 deletions

View File

@@ -236,6 +236,29 @@ pub const BuildMessage = struct {
return this.toPrimitive(globalThis, callframe) catch jsc.JSValue.jsNull();
}
/// Create a synthetic stack frame for error stack traces
pub export fn BuildMessage__createSyntheticStackFrame(this: *BuildMessage, frame: *jsc.ZigStackFrame) void {
const location = this.msg.data.location orelse {
frame.* = jsc.ZigStackFrame.Zero;
return;
};
frame.* = .{
.function_name = bun.String.empty,
.source_url = bun.String.init(location.file),
.position = .{
.line = jsc.ZigStackFramePosition.SourcePosition.init(location.line),
.column = jsc.ZigStackFramePosition.SourcePosition.init(location.column),
.line_stop = jsc.ZigStackFramePosition.SourcePosition.invalid,
.column_stop = jsc.ZigStackFramePosition.SourcePosition.invalid,
.expression_start = jsc.ZigStackFramePosition.SourcePosition.invalid,
},
.code_type = .None,
.is_async = false,
.remapped = true, // Mark as remapped so it's not processed again
};
}
pub export fn BuildMessage__finalize(this: *BuildMessage) void {
this.finalize();
}

View File

@@ -305,6 +305,29 @@ pub const ResolveMessage = struct {
return this.toPrimitive(globalThis, callframe) catch jsc.JSValue.jsNull();
}
/// Create a synthetic stack frame for error stack traces
pub export fn ResolveMessage__createSyntheticStackFrame(this: *ResolveMessage, frame: *jsc.ZigStackFrame) void {
const location = this.msg.data.location orelse {
frame.* = jsc.ZigStackFrame.Zero;
return;
};
frame.* = .{
.function_name = bun.String.empty,
.source_url = bun.String.init(location.file),
.position = .{
.line = jsc.ZigStackFramePosition.SourcePosition.init(location.line),
.column = jsc.ZigStackFramePosition.SourcePosition.init(location.column),
.line_stop = jsc.ZigStackFramePosition.SourcePosition.invalid,
.column_stop = jsc.ZigStackFramePosition.SourcePosition.invalid,
.expression_start = jsc.ZigStackFramePosition.SourcePosition.invalid,
},
.code_type = .None,
.is_async = false,
.remapped = true, // Mark as remapped so it's not processed again
};
}
pub export fn ResolveMessage__finalize(this: *ResolveMessage) void {
this.finalize();
}