You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1a8adb1
Browse filesBrowse the repository at this point in the historyBrowse files
Original commit message:
[api][module] Return a Promise from Module::Evaluate()
Module evaluation always produces a Promise, but the public API exposed
the result as MaybeLocal<Value>, and for synthetic modules it could even
hand back the raw, non-Promise value returned by the embedder's
evaluation steps. Embedders therefore had to defensively cast the
result, and the actual contract was invisible in the type system.
This CL makes the contract explicit:
- SyntheticModule::Evaluate() now returns the top-level capability
Promise instead of the raw value produced by the evaluation steps, so
the completion value is always a Promise, matching source text
modules and the documented behavior.
- SyntheticModule::Evaluate() nows CHECK if callback result from
EvaluationSteps is a Promise. The reasoning behind it is that
the behavior for an embedder that relies on non-promise result
was already inconsistent, given the first call would return the
result form callback (an arbitrary Local<Value>), but subsequent
calls for module->Evaluate() would return the capability with
`undefined` as result.
- Module::Evaluate() and their variant now returns
`MaybeDirectHandle<JSPromise>` to be more explicit by the return
type.
Bug: 531396274
Change-Id: Ifbfed4f849bb47d8db1e022bfb750d9ad2d6308b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8131138
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Caio Lima <caiolima@igalia.com>
Reviewed-by: Olivier Flückiger <olivf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#109010}
Refs: v8/v8@e778593
Co-authored-by: Caio Lima <caiolima@igalia.com>
0 commit comments