You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
On Windows 11 using Docker and Supabase CLI to deploy a Supabase Edge Function, it fails to correctly import local files that are inside of the function directory (like a libs.ts file). I searched CLI versions to determine where this started, and I found that it works fine on CLI v1.186.3 - but when upgrading the CLI to version 1.187.0 or beyond, it is unable to import the local module, and can't boot the worker on Supabase.
It is perfectly reproducible on my machine, with only the CLI version upgrade to 1.187.0 and beyond causing the problem.
To Reproduce
Steps to reproduce the behavior:
Under supabase/functions/test, create index.ts file
Under supabase/functions/test, create libs.ts file
// supabase/functions/test/libs.ts
type Params = {
foo: string;
};
export const processParams = (params: Params) => {
if (!params.foo) {
throw new Error("Missing foo parameter");
}
return {
foo: params.foo.toUpperCase(),
timestamp: new Date().toISOString(),
};
};
Use scoop to install supabase v1.187.0 scoop uninstall supabase && scoop install [email protected]
Deploy the Supabase Edge Function supabase functions deploy test
Make a POST request with the "foo" parameter included in the body. This will be the error response: {"code":"BOOT_ERROR","message":"Function failed to start (please check logs)"}
Inside of the function logs, it says this: worker boot error: Module not found: file:///Users/danie/<redacted>/supabase/functions/test/libs.ts
Deploy Supabase Edge Function again supabase functions deploy test
Make a POST request with the "foo" parameter again. Now we see the correct response, and it has run successfully: {"success":true,"processedParams":{"foo":"BAR","timestamp":"2024-11-10T08:41:26.403Z"}}
Expected behavior
The Supabase Edge Function should be able to import local modules in the specific function's directory, using relative import syntax. E.g. import { processParams } from "./libs.ts"; should be valid and work, not causing errors. Or there should be clear guidelines on how to do it otherwise.
Screenshots
N/A
System information
Rerun the failing command with --create-ticket flag.
From my understanding, it seems to work for people on MacOS or Linux. Perhaps it incorrectly maps the imports to the absolute paths in Windows, where it works fine on other OS?
Maybe this is intentional? If so, is there an explanation on how we can import local files correctly? I tried using import_maps.json and deno.json, and both of these lead to the exact same issue as described above.
Thanks!
The text was updated successfully, but these errors were encountered:
I've just tried this out with the latest 1.223.10 of the cli on a Windows11 machine and wasn't able to reproduce. So this might have been fixed by one of the edge-runtime update.
Could you please try again with latest version @danablend and report back ?
Describe the bug
On Windows 11 using Docker and Supabase CLI to deploy a Supabase Edge Function, it fails to correctly import local files that are inside of the function directory (like a libs.ts file). I searched CLI versions to determine where this started, and I found that it works fine on CLI v1.186.3 - but when upgrading the CLI to version 1.187.0 or beyond, it is unable to import the local module, and can't boot the worker on Supabase.
It is perfectly reproducible on my machine, with only the CLI version upgrade to 1.187.0 and beyond causing the problem.
To Reproduce
Steps to reproduce the behavior:
Use scoop to install supabase v1.187.0
scoop uninstall supabase && scoop install [email protected]
Deploy the Supabase Edge Function
supabase functions deploy test
Make a POST request with the "foo" parameter included in the body. This will be the error response:
{"code":"BOOT_ERROR","message":"Function failed to start (please check logs)"}
Inside of the function logs, it says this:
worker boot error: Module not found: file:///Users/danie/<redacted>/supabase/functions/test/libs.ts
To fix, downgrade Supabase CLI to 1.186.3
scoop uninstall [email protected] && scoop install [email protected]
Deploy Supabase Edge Function again
supabase functions deploy test
Make a POST request with the "foo" parameter again. Now we see the correct response, and it has run successfully:
{"success":true,"processedParams":{"foo":"BAR","timestamp":"2024-11-10T08:41:26.403Z"}}
Expected behavior
The Supabase Edge Function should be able to import local modules in the specific function's directory, using relative import syntax. E.g.
import { processParams } from "./libs.ts";
should be valid and work, not causing errors. Or there should be clear guidelines on how to do it otherwise.Screenshots
N/A
System information
Rerun the failing command with
--create-ticket
flag.Additional context
I suspect this is the code where the issue was introduced:
d8761b5
In the latest version, it is here:
https://github.com/supabase/cli/blob/develop/internal/functions/deploy/bundle.go
From my understanding, it seems to work for people on MacOS or Linux. Perhaps it incorrectly maps the imports to the absolute paths in Windows, where it works fine on other OS?
Maybe this is intentional? If so, is there an explanation on how we can import local files correctly? I tried using import_maps.json and deno.json, and both of these lead to the exact same issue as described above.
Thanks!
The text was updated successfully, but these errors were encountered: