summaryrefslogtreecommitdiff
path: root/runtime/ops/worker_host.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-03-11 22:18:03 +0000
committerGitHub <noreply@github.com>2024-03-11 23:18:03 +0100
commitd69aab62b0789dd54b8c09b54af022a38f060b5b (patch)
treee99a5a3217d6aeee379bc592bfa33702dc2d6de8 /runtime/ops/worker_host.rs
parent28b362adfc49324e20af5ecb1530f89eb91c4ed5 (diff)
fix(ext/node): make worker setup synchronous (#22815)
This commit fixes race condition in "node:worker_threads" module were the first message did a setup of "threadId", "workerData" and "environmentData". Now this data is passed explicitly during workers creation and is set up before any user code is executed. Closes https://github.com/denoland/deno/issues/22783 Closes https://github.com/denoland/deno/issues/22672 --------- Co-authored-by: Satya Rohith <me@satyarohith.com>
Diffstat (limited to 'runtime/ops/worker_host.rs')
-rw-r--r--runtime/ops/worker_host.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs
index ee9f0dc5e..d1b318f0f 100644
--- a/runtime/ops/worker_host.rs
+++ b/runtime/ops/worker_host.rs
@@ -35,6 +35,7 @@ pub struct CreateWebWorkerArgs {
pub permissions: PermissionsContainer,
pub main_module: ModuleSpecifier,
pub worker_type: WebWorkerType,
+ pub maybe_worker_metadata: Option<JsMessageData>,
}
pub type CreateWebWorkerCb = dyn Fn(CreateWebWorkerArgs) -> (WebWorker, SendableWebWorkerHandle)
@@ -121,6 +122,7 @@ pub struct CreateWorkerArgs {
fn op_create_worker(
state: &mut OpState,
#[serde] args: CreateWorkerArgs,
+ #[serde] maybe_worker_metadata: Option<JsMessageData>,
) -> Result<WorkerId, AnyError> {
let specifier = args.specifier.clone();
let maybe_source_code = if args.has_source_code {
@@ -189,6 +191,7 @@ fn op_create_worker(
permissions: worker_permissions,
main_module: module_specifier.clone(),
worker_type,
+ maybe_worker_metadata,
});
// Send thread safe handle from newly created worker to host thread