summaryrefslogtreecommitdiff
path: root/runtime/web_worker.rs
AgeCommit message (Collapse)Author
2021-11-29fix(workers): Make `worker.terminate()` not immediately kill the isolate ↵Andreu Botella
(#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-28refactor: add deno_fetch::Options for init (#12904)Ryan Dahl
deno_fetch::init has a lot of parameters and generic on two types that keeps expanding over time. This refactor adds deno_fetch::Options struct for more clearly defining the various parameters.
2021-11-08refactor: move `mod tokio_util` to runtime (#12332)Bert Belder
This avoids a bunch of duplicated code.
2021-11-03fix: Deno.emit crashes with BorrowMutError (#12627)Ryan Dahl
Warn on await_holding_refcell_ref clippy rule to avoid this in the future. Fixes #12453
2021-11-01feat(ext/fetch): support fetching local files (#12545)Kitson Kelly
Closes #11925 Closes #2150 Co-authored-by: Bert Belder <bertbelder@gmail.com>
2021-10-10refactor(metrics): move to core (#12386)Aaron O'Mullan
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
2021-10-08feat(runtime): allow passing extensions via Worker options (#12362)Aaron O'Mullan
2021-10-05refactor(runtime): Worker bootstrap options (#12299)Aaron O'Mullan
2021-10-01fix(runtime/js/workers): throw errors instead of using an op (#12249)Nayeem Rahman
2021-09-29feat: support serializing `WebAssembly.Module` objects (#12140)Andreu Botella
2021-09-25refactor: Remove unused code (#12210)Ryan Dahl
2021-09-23refactor: Remove depreated Worker::execute_module (#12203)Ryan Dahl
2021-09-22fix(workers): Don't panic when a worker's parent thread stops running (#12156)Andreu Botella
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-18fix(core): prevent multiple main module loading (#12128)Bartek Iwańczuk
This commit fixes a problem where loading and executing multiple modules leads to all of the having "import.meta.main" set to true. Following Rust APIs were deprecated: - deno_core::JsRuntime::load_module - deno_runtime::Worker::execute_module - deno_runtime::WebWorker::execute_module Following Rust APIs were added: - deno_core::JsRuntime::load_main_module - deno_core::JsRuntime::load_side_module - deno_runtime::Worker::execute_main_module - deno_runtime::Worker::execute_side_module - deno_runtime::WebWorker::execute_main_module Trying to load multiple "main" modules into the runtime now results in an error. If user needs to load additional "non-main" modules they should use APIs for "side" module.
2021-08-25feat(fetch): mTLS client certificates for fetch() (#11721)Sean Michael Wykes
This commit adds support for specifying client certificates when using fetch, by means of `Deno.createHttpClient`.
2021-08-25refactor: cleanup Inspector and InspectorServer implementations (#11837)Bartek Iwańczuk
2021-08-20refactor: fix typo in web_worker.rs (#11792)Ikko Ashimine
2021-08-18fix(runtime): event loop panics in classic workers (#11756)Luca Casonato
Classic worker scripts are now executed in the context of a Tokio runtime. This does mean we can not spawn more tokio runtimes in "op_worker_sync_fetch". We instead spawn a new thread there, that can create a new Tokio runtime that we can use to block the worker thread.
2021-08-16feat(runtime): support classic workers for internal testing (#11338)Andreu Botella
This commit implements classic workers, but only when the `--enable-testing-features-do-not-use` flag is provided. This change is not user facing. Classic workers are used extensively in WPT tests. The classic workers do not support loading from disk, and do not support TypeScript. Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-08-10refactor: --unsafely-ignore-certificate-errors (#11629)Bartek Iwańczuk
2021-08-09feat: Add --unsafely-treat-insecure-origin-as-secure flag to disable SSL ↵TheAifam5
verification (#11324) This commit adds "--unsafely-treat-insecure-origin-as-secure" flag that allows to disable SSL verification for all domains, or specific domains if they were passed as an argument to the flag. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-08-07feat(tls): Optionally support loading native certs (#11491)Justin Chase
This commit adds "DENO_TLS_CA_STORE" env variable to support optionally loading certificates from the users local certificate store. This will allow them to successfully connect via tls with corporate and self signed certs provided they have them installed in their keystore. It also allows them to deal with revoked certs by simply updating their keystore without having to upgrade Deno. Currently supported values are "mozilla", "system" or empty value.
2021-08-06feat: ffi to replace plugins (#11152)Elias Sjögreen
This commit removes implementation of "native plugins" and replaces it with FFI API. Effectively "Deno.openPlugin" API was replaced with "Deno.dlopen" API.
2021-07-30chore(core): use oneshot channel in mod_evaluate() (#11556)Ben Noordhuis
Oneshot is more appropriate because mod_evaluate() only sends a single value. It also makes it easier to use it correctly. As an embedder, I wasn't sure if I'm expected to drain the channel or not.
2021-07-29feat(runtime): implement navigator.hardwareConcurrency (#11448)Divy Srivastava
This commit implements "navigator.hardwareConcurrency" API, which supersedes "Deno.systemCpuInfo()" API (which was removed in this commit).
2021-07-28feat(extensions/fetch): extend init options (#11528)Satya Rohith
2021-07-22fix: support --cert flag for tls connect APIs (#11484)Luca Casonato
2021-07-12refactor: deno_http op crate (#11335)Luca Casonato
2021-07-11Revert "Remove unstable native plugins (#10908)"Ryan Dahl
This reverts commit 7dd4090c2a3dc0222fd6ff611eeb2bd69cd28224.
2021-07-08feat(core): return v8::Value from JsRuntime::execute_script (#11129)Bartek Iwańczuk
This commit changes return type of JsRuntime::execute_script to include v8::Value returned from evaluation. When embedding deno_core it is sometimes useful to be able to inspect script evaluation value without the hoops of adding ops to store the value on the OpState. v8::Global<v8::Value> is used so consumers don't have to pass scope themselves.
2021-07-06feat: support SharedArrayBuffer sharing between workers (#11040)Luca Casonato
This commit adds support for sharing SABs between workers.
2021-07-05refactor: asynchronous blob backing store (#10969)Jimmy Wärting
Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-07-02Remove unstable native plugins (#10908)Bartek Iwańczuk
This commit removes implementation of native plugins alongside the unstable "Deno.openPlugin()" API.
2021-06-30feat(inspector): improve inspector prompt in Chrome Devtools (#11187)Bartek Iwańczuk
This commit improves how Deno inspector presents itself in Chrome Devtools.
2021-06-29feat: Add "deno_net" extension (#11150)Bartek Iwańczuk
This commits moves implementation of net related APIs available on "Deno" namespace to "deno_net" extension. Following APIs were moved: - Deno.listen() - Deno.connect() - Deno.listenTls() - Deno.serveHttp() - Deno.shutdown() - Deno.resolveDns() - Deno.listenDatagram() - Deno.startTls() - Deno.Conn - Deno.Listener - Deno.DatagramConn
2021-06-22feat: transfer MessagePort between workers (#11076)Luca Casonato
Add support for transferring `MessagePort`s between workers.
2021-06-22feat(fetch): add programmatic proxy (#10907)Tomofumi Chiba
This commit adds new options to unstable "Deno.createHttpClient" API. "proxy" and "basicAuth" options were added that allow to use custom proxy when client instance is passed to "fetch" API.
2021-06-22refactor: unify JavaScript script execution method (#11043)Bartek Iwańczuk
This commit renames "JsRuntime::execute" to "JsRuntime::execute_script". Additionally same renames were applied to methods on "deno_runtime::Worker" and "deno_runtime::WebWorker". A new macro was added to "deno_core" called "located_script_name" which returns the name of Rust file alongside line no and col no of that call site. This macro is useful in combination with "JsRuntime::execute_script" and allows to provide accurate place where "one-off" JavaScript scripts are executed for internal runtime functions. Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
2021-06-21refactor(core): always attach inspector to isolate (#11042)Bartek Iwańczuk
This commit changes "deno_core::JsRuntime" to always create "deno_core::JsRuntimeInspector" instance.
2021-06-17chore: upgrade Rust to 1.53.0 (#11021)Yusuke Tanaka
2021-06-10refactor: merge deno_file crate into deno_web (#10914)Bartek Iwańczuk
This refactor makes it so there's one less crate to publish on each release.
2021-05-26refactor: move JsRuntimeInspector to deno_core (#10763)Bartek Iwańczuk
This commit moves implementation of "JsRuntimeInspector" to "deno_core" crate. To achieve that following changes were made: * "Worker" and "WebWorker" no longer own instance of "JsRuntimeInspector", instead it is now owned by "deno_core::JsRuntime". * Consequently polling of inspector is no longer done in "Worker"/"WebWorker", instead it's done in "deno_core::JsRuntime::poll_event_loop". * "deno_core::JsRuntime::poll_event_loop" and "deno_core::JsRuntime::run_event_loop", now accept "wait_for_inspector" boolean that tells if event loop should still be "pending" if there are active inspector sessions - this change fixes the problem that inspector disconnects from the frontend and process exits once the code has stopped executing.
2021-05-26refactor: Rewrite Inspector implementation (#10725)Bartek Iwańczuk
This commit refactors implementation of inspector. The intention is to be able to move inspector implementation to "deno_core". Following things were done to make that possible: * "runtime/inspector.rs" was split into "runtime/inspector/mod.rs" and "runtime/inspector/server.rs", separating inspector implementation from Websocket server implementation. * "DenoInspector" was renamed to "JsRuntimeInspector" and reference to "server" was removed from the structure, making it independent of Websocket server used to connect to Chrome Devtools. * "WebsocketSession" was renamed to "InspectorSession" and rewritten in such a way that it's not tied to Websockets anymore; instead it accepts a pair of "proxy" channel ends that allow to integrate the session with different "transports". * "InspectorSession" was renamed to "LocalInspectorSession" to better indicate that it's an "in-memory" session and doesn't require Websocket server. It was also rewritten in such a way that it uses "InspectorSession" from previous point instead of reimplementing "v8::inspector::ChannelImpl" trait; this is done by using the "proxy" channels to communicate with the V8 session. Consequently "LocalInspectorSession" is now a frontend to "InspectorSession". This introduces a small inconvenience that awaiting responses for "LocalInspectorSession" requires to concurrently poll worker's event loop. This arises from the fact that "InspectorSession" is now owned by "JsRuntimeInspector", which in turn is owned by "Worker" or "WebWorker". To ease this situation "Worker::with_event_loop" helper method was added, that takes a future and concurrently polls it along with the event loop (using "tokio::select!" macro inside a loop).
2021-05-23feat(extensions): BroadcastChannel WPT conformanceBen Noordhuis
Replaces the file-backed provider by an in-memory one because proper file locking is a hard problem that detracts from the proof of concept. Teach the WPT runner how to extract tests from .html files because all the relevant tests in test_util/wpt/webmessaging/broadcastchannel are inside basics.html and interface.html.
2021-05-23feat(extensions): add BroadcastChannelBen Noordhuis
Co-Authored-By: Ben Noordhuis <info@bnoordhuis.nl> Fixes: #10354
2021-05-11feat(runtime/worker): Structured cloning worker message passing (#9323)Tim Ramlot
This commit upgrade "Worker.postMessage()" implementation to use structured clone algorithm instead of non-spec compliant JSON serialization.
2021-05-02refactor(runtime): use Extensions (#10461)Aaron O'Mullan
2021-04-30refactor(core): provide builtins as an Extension (#10449)Aaron O'Mullan
2021-04-30refactor(core): initialize extensions in runtime constructor (#10421)Aaron O'Mullan
This ensures that provided extensions are all correctly setup and ready to use once the JsRuntime constructor returns Note: this will also initialize ops for to-be-snapshotted runtimes
2021-04-28core: introduce extensions (#9800)Aaron O'Mullan
Extensions allow declarative extensions to "JsRuntime" (ops, state, JS or middleware). This allows for: - `op_crates` to be plug-and-play & self-contained, reducing complexity leaked to consumers - op middleware (like metrics_op) to be opt-in and for new middleware (unstable, tracing,...) - `MainWorker` and `WebWorker` to be composable, allowing users to extend workers with their ops whilst benefiting from the other infrastructure (inspector, etc...) In short extensions improve deno's modularity, reducing complexity and leaky abstractions for embedders and the internal codebase.