Open miniBill opened 8 months ago
I'm trying to define a custom task.
// custom-backend-task.js import child_process from "node:child_process"; /** * @param { string[] } args * @returns { Promise<number> } */ export async function spawn(args) { const child = child_process.spawn(args[0], args.splice(1)); child.on("error", (err) => { console.log("Error", err); }); console.log("Pid:", child.pid); return child.pid; }
-- Main.elm run = [...] (spawn "socat" [...]) spawn : String -> List String -> BackendTask FatalError Int spawn command args = BackendTask.Custom.run "spawn" (Json.Encode.list Json.Encode.string (command :: args)) Json.Decode.int |> BackendTask.allowFatal
The output is
Pid: 1462229 BackendTask.Custom.run "spawn": 2.992ms -- HTTP ERROR --------------- BadBody: INTERNAL ERROR - expected requestelm-pages-internal://port
I can see socat running, and I don't know what is wrong that causes the internal error.
socat
The issue is the splice(1) which mutates args and causes the request to change hash and not be matched when returning.
splice(1)
args
I'm trying to define a custom task.
The output is
I can see
socat
running, and I don't know what is wrong that causes the internal error.