Skip to content

Commit 1d1f436

Browse files
committed
fix: expose execution_id as a environment variable
1 parent b903121 commit 1d1f436

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

crates/base/src/deno_runtime.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ impl DenoRuntime {
334334

335335
{
336336
//run inside a closure, so op_state_rc is released
337-
let env_vars = env_vars.clone();
338337
let op_state_rc = js_runtime.op_state();
339338
let mut op_state = op_state_rc.borrow_mut();
340-
op_state.put::<sb_env::EnvVars>(env_vars);
339+
340+
let mut env_vars = env_vars.clone();
341341

342342
if conf.is_events_worker() {
343343
// if worker is an events worker, assert events_rx is to be available
@@ -347,6 +347,13 @@ impl DenoRuntime {
347347

348348
if conf.is_user_worker() {
349349
let conf = conf.as_user_worker().unwrap();
350+
351+
// set execution id for user workers
352+
env_vars.insert(
353+
"SB_EXECUTION_ID".to_string(),
354+
conf.key.map_or("".to_string(), |k| k.to_string()),
355+
);
356+
350357
if let Some(events_msg_tx) = conf.events_msg_tx.clone() {
351358
op_state.put::<mpsc::UnboundedSender<WorkerEventWithMetadata>>(events_msg_tx);
352359
op_state.put::<EventMetadata>(EventMetadata {
@@ -355,6 +362,8 @@ impl DenoRuntime {
355362
});
356363
}
357364
}
365+
366+
op_state.put::<sb_env::EnvVars>(env_vars);
358367
}
359368

360369
let main_module_id = js_runtime

0 commit comments

Comments
 (0)