Skip to content

Commit fcae33d

Browse files
committed
fix: show the actual deno cli version in Deno.version
(cherry picked from commit b4b5b9e)
1 parent 2def458 commit fcae33d

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

crates/base/src/deno_runtime.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use deno_tls::rustls::RootCertStore;
1818
use deno_tls::RootCertStoreProvider;
1919
use futures_util::future::poll_fn;
2020
use log::{error, trace};
21+
use once_cell::sync::OnceCell;
2122
use sb_core::conn_sync::ConnSync;
2223
use sb_core::util::sync::AtomicFlag;
2324
use serde::de::DeserializeOwned;
@@ -78,6 +79,8 @@ fn get_error_class_name(e: &AnyError) -> &'static str {
7879
sb_core::errors_rt::get_error_class_name(e).unwrap_or("Error")
7980
}
8081

82+
pub static MAYBE_DENO_VERSION: OnceCell<String> = OnceCell::new();
83+
8184
pub struct DenoRuntime {
8285
pub js_runtime: JsRuntime,
8386
pub env_vars: HashMap<String, String>, // TODO: does this need to be pub?
@@ -303,11 +306,16 @@ impl DenoRuntime {
303306

304307
// Bootstrapping stage
305308
let script = format!(
306-
"globalThis.bootstrapSBEdge({}, {}, {}, '{}')",
309+
// opts, isUserWorker, isEventsWorker, edgeRuntimeVersion, denoVersion
310+
"globalThis.bootstrapSBEdge({}, {}, {}, '{}', '{}')",
307311
deno_core::serde_json::json!({ "target": env!("TARGET") }),
308312
conf.is_user_worker(),
309313
conf.is_events_worker(),
310-
version.unwrap_or("0.1.0")
314+
version.unwrap_or("0.1.0"),
315+
MAYBE_DENO_VERSION
316+
.get()
317+
.map(|it| &**it)
318+
.unwrap_or("UNKNOWN")
311319
);
312320

313321
js_runtime
@@ -903,7 +911,7 @@ mod test {
903911
.to_vec();
904912
assert_eq!(
905913
deno_version_array.first().unwrap().as_str().unwrap(),
906-
"supabase-edge-runtime-0.1.0"
914+
"supabase-edge-runtime-0.1.0 (compatible with Deno vUNKNOWN)"
907915
);
908916
assert_eq!(
909917
deno_version_array.get(1).unwrap().as_str().unwrap(),

crates/cli/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod logger;
22

33
use anyhow::{anyhow, bail, Error};
44
use base::commands::start_server;
5+
use base::deno_runtime::MAYBE_DENO_VERSION;
56
use base::rt_worker::worker_pool::{SupervisorPolicy, WorkerPoolPolicy};
67
use base::server::WorkerEntrypoints;
78
use clap::builder::{FalseyValueParser, TypedValueParser};
@@ -102,6 +103,8 @@ fn cli() -> Command {
102103
//}
103104

104105
fn main() -> Result<(), anyhow::Error> {
106+
MAYBE_DENO_VERSION.get_or_init(|| env!("DENO_VERSION").to_string());
107+
105108
let runtime = tokio::runtime::Builder::new_current_thread()
106109
.enable_all()
107110
.build()

crates/sb_core/js/bootstrap.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const deleteDenoApis = (apis) => {
233233
});
234234
};
235235

236-
globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => {
236+
globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, edgeRuntimeVersion, denoVersion) => {
237237
// We should delete this after initialization,
238238
// Deleting it during bootstrapping can backfire
239239
delete globalThis.__bootstrap;
@@ -255,7 +255,8 @@ globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => {
255255
...opts,
256256
});
257257

258-
ObjectDefineProperty(globalThis, 'SUPABASE_VERSION', readOnly(String(version)));
258+
ObjectDefineProperty(globalThis, 'SUPABASE_VERSION', readOnly(String(edgeRuntimeVersion)));
259+
ObjectDefineProperty(globalThis, 'DENO_VERSION', readOnly(denoVersion))
259260

260261
// set these overrides after runtimeStart
261262
ObjectDefineProperties(denoOverrides, {
@@ -265,7 +266,7 @@ globalThis.bootstrapSBEdge = (opts, isUserWorker, isEventsWorker, version) => {
265266
args: readOnly([]), // args are set to be empty
266267
mainModule: getterOnly(() => ops.op_main_module()),
267268
version: getterOnly(() => ({
268-
deno: `supabase-edge-runtime-${globalThis.SUPABASE_VERSION}`,
269+
deno: `supabase-edge-runtime-${globalThis.SUPABASE_VERSION} (compatible with Deno v${globalThis.DENO_VERSION})`,
269270
v8: '11.6.189.12',
270271
typescript: '5.1.6',
271272
})),

0 commit comments

Comments
 (0)