edge-runtime: InvalidWorkerCreation: worker boot error: failed to create the graph
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When I serve a function locally that imports a file outside /supabase/functions I get the error:
{"code":"BOOT_ERROR","message":"Worker failed to boot (please check logs)"}
The error does not occur when launching the function with $ deno run.
Logs
serving the request with ***/supabase/functions/hello-world
failed to create the graph
An error has occured
InvalidWorkerCreation: worker boot error: failed to create the graph
at async UserWorker.create (ext:sb_user_workers/user_workers.js:145:15)
at async Object.handler (file:///root/index.ts:154:22)
at async respond (ext:sb_core_main_js/js/http.js:163:14) {
name: "InvalidWorkerCreation"
}
Reproduce steps
$ supabase functions new hello-world- Replace
hello-world/index.tswith:// @deno-types="npm:@types/express@4.17.15" import express, { Request, Response } from 'npm:express@4.21.0'; import { hello } from '../../../lib.ts'; const app = express(); app.use(express.json()); const port = 3000; app.get('/hello-world', (_: Request, res: Response) => { res.send(hello()); }); app.listen(port, () => {}); - create a file
lib.tsin the project root containing the following:export function hello() : string { return 'Hello World!'; } - run the function with supabase:
$ supabase functions serve hello-world --no-verify-jwtthe error occurs - run the function with deno (from within the
/supabase/functions/hello-worldfolder):$ deno run -A index.tsno issues
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (5 by maintainers)
This issue seems to be caused by the CLI only mounting the /supabase/functions directory that exists on the host machine into the edge runtime container. From the container’s perspective, it looks like no files exist in the parent directory, and as a result,
lib.tsfails to load.And simply exposing a
failed to create the graphmessage seems problematic. We actually have a source about why the graph failed to be created for some reason, but we didn’t render it to the console or in the response.Regarding the mount issue you’re having, there’s nothing the edge runtime can do to fix it, but the error message needs improvement, so I’ll be submitting a PR soon.
–
Error message should be able to be improved as follows:
Response
Console
Well…it’s complicated, but it’s possible…if you’re good with Docker.
Finding the file in issue is possible with strace. You can access the shell of a container running edge runtime via
docker exec -it <edge runtime container id> /bin/bash.From there, you need to install the necessary packages for tracing by typing
apt-get update && apt-get install -y htop strace.You should be able to find the pid of the edge runtime using htop, which will allow you to observe the syscalls that the edge runtime is calling in real-time via strace.
After you type strace, as shown below, the shell will log syscalls until you press Ctrl+C.
Now send a request and observe the logs that are written to the shell. If you’ve followed these instructions well, you should have a syscall logged in your shell that failed to open the file, like this.
I hope you find these instructions helpful. Have a great day!
Yeah in such a case like yours, the syscall log would look normal, so the method I suggested instructions above would not have been able to resolve the issue.
There are many other cases where a graph error is emitted besides the file not being found, so I will submit a patch in the near future to expose the detailed error.
Yeah, it should because
supabase/functionsis the mount point of its container. All subpaths for this path should be recognizable from edge runtime.