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:
Don Isaac
2025-04-09 13:27:51 -07:00
committed by GitHub
parent 44f70b4301
commit 44f252539a
11 changed files with 79 additions and 64 deletions

View File

@@ -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));
}
}
};
}