mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Fix ResolveMessage empty message property by explicitly setting it after object creation
The issue was that JavaScript's Error constructor was overriding the message property with an empty string after the ResolveMessage object was created. This happened because ResolveMessage inherits from Error (inheritsFromError: true) and the Error constructor sets message = '' by default. The fix explicitly sets the message property on the JavaScript object after creation using the formatted error text from msg.data.text, ensuring that the proper error messages are displayed in tests. Fixes test failures in: - test/js/node/missing-module.test.js - test/js/bun/resolve/resolve-error.test.ts - test/js/node/module/node-module-module.test.js - test/js/node/module/require-extensions.test.ts - test/bundler/bundler_plugin.test.ts
This commit is contained in:
@@ -175,7 +175,14 @@ pub const ResolveMessage = struct {
|
||||
.allocator = allocator,
|
||||
.referrer = bun.String.cloneUTF8(referrer),
|
||||
};
|
||||
return resolve_error.toJS(globalThis);
|
||||
|
||||
const js_value = resolve_error.toJS(globalThis);
|
||||
|
||||
// Explicitly set the message property to override any empty message set by Error constructor
|
||||
const message_str = ZigString.init(resolve_error.msg.data.text);
|
||||
js_value.put(globalThis, ZigString.static("message"), message_str.toJS(globalThis));
|
||||
|
||||
return js_value;
|
||||
}
|
||||
|
||||
pub fn getPosition(
|
||||
|
||||
Reference in New Issue
Block a user