Skip to content

Commit

Permalink
fixed timing and null in reason
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Jul 4, 2022
1 parent 6d6050b commit 31a108b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/ops_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub(crate) fn init_builtins() -> Extension {
op_metrics::decl(),
op_format_file_name::decl(),
op_is_proxy::decl(),
op_next_task::decl(),
])
.ops(crate::ops_builtin_v8::init_builtins_v8())
.build()
Expand Down Expand Up @@ -189,3 +190,8 @@ fn op_format_file_name(file_name: String) -> String {
fn op_is_proxy(value: serde_v8::Value) -> bool {
value.v8_value.is_proxy()
}

/// Empty op that when awaited forces a macrotask to run. Useful for
/// "unhandledrejection" event.
#[op]
async fn op_next_task() {}
2 changes: 1 addition & 1 deletion ext/web/02_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@
cancelable,
composed,
promise,
reason = null,
reason,
} = {},
) {
super(type, {
Expand Down
2 changes: 1 addition & 1 deletion runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ delete Intl.v8BreakIterator;
default:
return;
}
queueMicrotask(() => {
core.opAsync("op_next_task").then(() => {
const hasPendingException = core.opSync(
"op_has_pending_promise_exception",
promise,
Expand Down

0 comments on commit 31a108b

Please sign in to comment.