mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
fix: mark JSPromise.rejectedPromiseValue as deprecated (#18549)
### What does this PR do? `JSPromise.rejectedPromiseValue` does not notify the VM about the promise it creates, meaning unhandled rejections created this way do not trigger `unhandledRejection`. This is leading to accidental error suppression in (likely) a lot of places. Additionally it returns a `JSValue` when really it should be returning a `*JSPromise`, making Zig bindings more type-safe. This PR renames `rejectedPromiseValue` to `dangerouslyCreateRejectedPromiseValueWithoutNotifyingVM` and marks it as deprecated. It does _not_ modify code calling this function, meaning no behavior changes should occur. We should slowly start replacing its usages with `rejectedPromise` ## Changelog - Rename `rejectedPromiseValue` to `dangerouslyCreateRejectedPromiseValueWithoutNotifyingVM` - Mark `JSPromise.asValue` as deprecated. It takes a `*JSGlobalObject` but never uses it. New code should use `toJS()` - Refactors `blob` to make null checks over `destination_blob.source` a release assertion - `ErrorBuilder.reject` uses `rejectedPromiseValue` when 1.3 feature flag is enabled
This commit is contained in:
@@ -73,7 +73,11 @@ pub fn ErrorBuilder(comptime code: Error, comptime fmt: [:0]const u8, Args: type
|
||||
|
||||
/// Turn this into a JSPromise that is already rejected.
|
||||
pub inline fn reject(this: @This()) JSC.JSValue {
|
||||
return JSC.JSPromise.rejectedPromiseValue(this.globalThis, code.fmt(this.globalThis, fmt, this.args));
|
||||
if (comptime bun.FeatureFlags.breaking_changes_1_3) {
|
||||
return JSC.JSPromise.rejectedPromise(this.globalThis, code.fmt(this.globalThis, fmt, this.args)).toJS();
|
||||
} else {
|
||||
return JSC.JSPromise.dangerouslyCreateRejectedPromiseValueWithoutNotifyingVM(this.globalThis, code.fmt(this.globalThis, fmt, this.args));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user