Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERNAL ERROR when calling custom task. #463

Open
miniBill opened this issue Mar 30, 2024 · 1 comment
Open

INTERNAL ERROR when calling custom task. #463

miniBill opened this issue Mar 30, 2024 · 1 comment

Comments

@miniBill
Copy link
Contributor

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.

@miniBill
Copy link
Contributor Author

miniBill commented Apr 1, 2024

The issue is the splice(1) which mutates args and causes the request to change hash and not be matched when returning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant