mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(runtime/web_worker): Use biased select when getting module result (#14553)
This commit is contained in:
parent
2f7f41533b
commit
cb884de2e9
6 changed files with 28 additions and 3 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -236,7 +236,7 @@ jobs:
|
|||
~/.cargo/registry/index
|
||||
~/.cargo/registry/cache
|
||||
~/.cargo/git/db
|
||||
key: 11-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
|
||||
key: 12-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}
|
||||
|
||||
# In main branch, always creates fresh cache
|
||||
- name: Cache build output (main)
|
||||
|
@ -252,7 +252,7 @@ jobs:
|
|||
!./target/*/*.zip
|
||||
!./target/*/*.tar.gz
|
||||
key: |
|
||||
11-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
|
||||
12-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
|
||||
|
||||
# Restore cache from the latest 'main' branch build.
|
||||
- name: Cache build output (PR)
|
||||
|
@ -268,7 +268,7 @@ jobs:
|
|||
!./target/*/*.tar.gz
|
||||
key: never_saved
|
||||
restore-keys: |
|
||||
11-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
|
||||
12-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
|
||||
|
||||
# Don't save cache after building PRs or branches other than 'main'.
|
||||
- name: Skip save cache (PR)
|
||||
|
|
|
@ -2714,6 +2714,14 @@ itest!(event_listener_error_immediate_exit {
|
|||
exit_code: 1,
|
||||
});
|
||||
|
||||
// https://github.com/denoland/deno/pull/14159#issuecomment-1092285446
|
||||
itest!(event_listener_error_immediate_exit_worker {
|
||||
args:
|
||||
"run --quiet --unstable -A event_listener_error_immediate_exit_worker.ts",
|
||||
output: "event_listener_error_immediate_exit_worker.ts.out",
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(set_timeout_error {
|
||||
args: "run --quiet set_timeout_error.ts",
|
||||
output: "set_timeout_error.ts.out",
|
||||
|
|
4
cli/tests/testdata/event_listener_error_immediate_exit_worker.ts
vendored
Normal file
4
cli/tests/testdata/event_listener_error_immediate_exit_worker.ts
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
new Worker(
|
||||
new URL("event_listener_error_immediate_exit.ts", import.meta.url).href,
|
||||
{ type: "module", deno: { namespace: true } },
|
||||
);
|
8
cli/tests/testdata/event_listener_error_immediate_exit_worker.ts.out
vendored
Normal file
8
cli/tests/testdata/event_listener_error_immediate_exit_worker.ts.out
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
1
|
||||
error: Uncaught (in worker "") Error: bar
|
||||
throw new Error("bar");
|
||||
^
|
||||
at [WILDCARD]/event_listener_error_immediate_exit.ts:4:9
|
||||
at [WILDCARD]/event_listener_error_immediate_exit.ts:11:1
|
||||
error: Uncaught (in promise) Error: Unhandled error in child worker.
|
||||
at [WILDCARD]
|
|
@ -557,6 +557,8 @@ impl WebWorker {
|
|||
let id = self.preload_module(module_specifier, false).await?;
|
||||
let mut receiver = self.js_runtime.mod_evaluate(id);
|
||||
tokio::select! {
|
||||
biased;
|
||||
|
||||
maybe_result = &mut receiver => {
|
||||
debug!("received module evaluate {:#?}", maybe_result);
|
||||
maybe_result.expect("Module evaluation result not provided.")
|
||||
|
@ -579,6 +581,8 @@ impl WebWorker {
|
|||
) -> Result<(), AnyError> {
|
||||
let mut receiver = self.js_runtime.mod_evaluate(id);
|
||||
tokio::select! {
|
||||
biased;
|
||||
|
||||
maybe_result = &mut receiver => {
|
||||
debug!("received worker module evaluate {:#?}", maybe_result);
|
||||
// If `None` is returned it means that runtime was destroyed before
|
||||
|
|
|
@ -304,6 +304,7 @@ impl MainWorker {
|
|||
) -> T {
|
||||
loop {
|
||||
tokio::select! {
|
||||
biased;
|
||||
result = &mut fut => {
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue