1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
Commit graph

15 commits

Author SHA1 Message Date
Andreu Botella
4a13c320d7
fix(workers): Make worker.terminate() not immediately kill the isolate (#12831)
Due to a bug in V8, terminating an isolate while a module with top-level
await is being evaluated would crash the process. This change makes it
so calling `worker.terminate()` will signal the worker to terminate at
the next iteration of the event loop, and it schedules a proper
termination of the worker's isolate after 2 seconds.
2021-11-29 13:37:44 +01:00
Nayeem Rahman
cd9193f126
fix(cli): short-circuit in prepare_module_load() (#12604) 2021-11-16 10:25:52 +11:00
Bartek Iwańczuk
e06515c5a9
feat(test): better formatting for test elapsed time (#12610)
This commit changes formatting of elapsed time in test
runner output.

Instead of "XXXms", reporter outputs one of:
- "XXXms" for <1000ms
- "XXs" for <60s
- "XXXmYYs" for >=60s
2021-10-30 22:49:46 +02:00
Nayeem Rahman
86f7bf89c5
fix(cli/tests): move worker test assertions out of message handlers (#12439) 2021-10-14 11:44:33 +02:00
Nayeem Rahman
7a22df9b76
fix(runtime/ops/worker_host): move permission arg parsing to Rust (#12297) 2021-10-13 13:04:44 -04:00
Kitson Kelly
a7baf5f2bb
refactor: integrate deno_graph into CLI (#12369) 2021-10-11 08:26:22 +11:00
Nayeem Rahman
330aaae936
tests: make worker test deterministic (#12361) 2021-10-07 22:53:09 +02:00
Nayeem Rahman
b354eaa247
fix(runtime/js/workers): throw errors instead of using an op (#12249) 2021-10-01 11:30:55 +02:00
David Sherret
c3e441c5b5
fix: worker environment permissions should accept an array (#12250) 2021-09-30 15:50:59 -04:00
Andreu Botella
a2632c86b1
fix: Don't panic when a worker is closed in the reactions to a wasm operation. (#12270) 2021-09-30 19:52:58 +02:00
Andreu Botella
1a6249c971
chore(workers): Test that closing a worker closes any child workers (#12215)
Before #12156, closing a worker which had children would cause a panic
(https://github.com/denoland/deno/issues/11342#issuecomment-918327693).

After that PR, closing a worker will also close any child workers.
2021-09-24 19:26:57 -07:00
Andreu Botella
5c5f4ea1d6
fix(workers): Don't panic when a worker's parent thread stops running (#12156)
This panic could happen in the following cases:

- A non-fatal error being thrown from a worker, that doesn't terminate
  the worker's execution, but propagates to the main thread without
  being handled, and makes the main thread terminate.
- A nested worker being alive while its parent worker gets terminated.
- A race condition if the main event loop terminates the worker as part
  of its last task, but the worker doesn't fully terminate before the
  main event loop stops running.

This panic happens because a worker's event loop should have pending ops
as long as the worker isn't closed or terminated – but if an event loop
finishes running while it has living workers, its associated
`WorkerThread` structs will be dropped, closing the channels that keep
those ops pending.

This change adds a `Drop` implementation to `WorkerThread`, which
terminates the worker without waiting for a response. This fixes the
panic, and makes it so nested workers are automatically terminated once
any of their ancestors is closed or terminated.

This change also refactors a worker's termination code into a
`WorkerThread::terminate()` method.

Closes #11342.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-09-22 18:02:15 +02:00
Andreu Botella
b7c2902c97
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.

The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.

The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.

The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 11:05:02 +02:00
Andreu Botella
c49eee551f
feat(workers): Make the Deno namespace configurable and unfrozen (#11888)
This is the worker counterpart of PR #11062.
2021-08-31 19:33:03 +02:00
David Sherret
15a763152f
chore: move test files to testdata directory (#11601) 2021-08-11 10:20:47 -04:00