Open Hexagon opened 3 months ago
Does this also happen if you write this same script in e.g. bash?
No, the problem seems to be related to Deno.execPath()
This works (using Deno.Command behind the scenes, and ["deno", "--version"]
as command):
import { Cron } from "jsr:@hexagon/croner";
import { spawn } from "jsr:@cross/utils";
// Check deno version every fifth second
new Cron("*/10 * * * * *", async () => {
try {
const result = await spawn(["deno","--version"]);
console.log("Success!");
console.log(result);
} catch (e) {
console.error("Failure!");
console.log(e);
}
});
... but this gives the said error (using [Deno.execPath(), "--version"]
as command);
import { Cron } from "jsr:@hexagon/croner";
import { spawn } from "jsr:@cross/utils";
// Check deno version every fifth second
new Cron("*/10 * * * * *", async () => {
try {
const result = await spawn([Deno.execPath(),"--version"]);
console.log("Success!");
console.log(result);
} catch (e) {
console.error("Failure!");
console.log(e);
}
});
Could it be that dax uses Deno.execPath()
internally, and Deno.execPath()
somehow get changed to /home/user/.deno/bin/deno (deleted)
when deno is upgraded?
Edit: Yep, just removing (deleted)
from Deno.execPath() resolves the problem in my example. This works [Deno.execPath().replace(" (deleted)",""),"--version"]
.
See this example checking deno version each 5th second
After changing deno version while the script is running, e.g.
deno upgrade --version 1.41.2
or similarAnd it does not recover unless restarting the main process