-
Notifications
You must be signed in to change notification settings - Fork 209
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
serve <name>
command errors when importing local files
#1093
Comments
The paths specified in {
"imports": {
"@backend/": "../",
} |
@sweatybridge Ok Ill try that, where should the |
The default location CLI loads from is |
I tried your suggestion but it still does not work: error: Module not found "file:///home/lib/cors.ts".
at file:///home/deno/functions/my-function/index.ts:9:29
2023/05/12 13:57:32 Sent Header: Host [docker]
2023/05/12 13:57:32 Sent Header: User-Agent [Go-http-client/1.1]
2023/05/12 13:57:32 Send Done
2023/05/12 13:57:32 Recv First Byte
Error: error executing command |
Ive been trying to figure out what these
we are simply trying to import from |
We mount the functions directories into a docker container for serving locally. I can't seem to reproduce on the latest version. |
Question: can the |
Yes, we added support for this recently #1061. You can find an example in the linked PR. |
Ok thats weird that it doesnt work for me... 😞 I am using v1.58.1, and running supabase using |
Hmm could you try |
Now that you mention docker, let me try deleting and recreating the stack... |
The container is called edge-runtime but it seems like the old deno-relay container is started instead. Can you also try |
To be clear all previous attemps have been specifying a function name: So my findings:
Error: Error response from daemon: Duplicate mount point: /home/deno/modules/c675a10248170410cad4e4a996152aad5ad7f2a817728186567122b6394d9419
I will continue to test with |
Hmm this error could come from resolving multiple modules with the same path because the base name is a hash of the original module path. |
Success was short lived, I am getting this error when calling the functions form the edge server:
serving the request with /home/deno/functions/my-function
worker thread panicked No such file or directory (os error 2)
Error: channel closed
at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:50:21)
at async Server.<anonymous> (file:///home/deno/main/index.ts:102:16)
at async Server.#respond (https://deno.land/[email protected]/http/server.ts:220:24)
failed to send the halt execution signal
failed to send the halt execution signal |
@sweatybridge I can confirm what I suspected... the Deno docker container only mounts the functions folder from the supabase directory. I expected to see a |
Is there a Your lib and services folder should be mounted under modules directory instead. |
No, I dont see that directory, only import_map.json (located inside "@backend/": "./",
"@components/": "./../src/components/",
"@utils/": "./../src/utils/", source code index file: import { corsHeaders } from '@backend/lib/cors.ts';
import { supabase } from '@backend/lib/supabase.client.ts'; |
Like I mentioned before, paths in import_map are relative to "@backend/": "../",
"@components/": "../../src/components/",
"@utils/": "../../src/utils/", |
Ah! ok that works! I do see the modules folder now! Still having trouble with some external does now that don't download from CDN but seems like the local files issue is solved! Some notes though:
|
serve
command errors when importing local filesserve <name>
command errors when importing local files
We have to keep deno relay for the time being while we iron out other issues with edge runtime. Once that's completed, we will default |
This is failing in my setup: Project Structure
supabase/functions/chat/index.ts
In "supabase_edge_runtime" Docker containerhome/deno
fallback_import_map.json {
"imports": {
"@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2",
"common/": "/home/deno/modules/4b0ed4fd36b0064d333d0ebb53b49ba5d84e9b130af0ab0c15f9924364d718c6/",
"core/": "./_core/"
},
"scopes": {}
} The deno LSP (vscode) is happy with this configuration, but when I try to invoke the
It seems like the
Also, when I try to run it with the
UpdateIf I update my import map to
Then it works (as suspected), but this breaks the imports in my local deno LSP... Also, it goes against what was said above:
So... I don't really understand what's going on... |
I am fetching the same issue, as supabase function working in local fine, but while deploying it throws error related file not found. any update on this ? |
If anyone came here with this issue, I was struggling with trying to get import_map to work, only to discover Deno stopped using import maps since 1.30: https://docs.deno.com/runtime/manual/getting_started/configuration_file#imports-and-scopes
So now you put your import aliases in the |
Bug report
Describe the bug
When running
supabase functions serve
, if a function imports a local file specified in theimport_map.json
file that is outside the function folder, the command fails. When running an edge-function using thedeno run --allow-all ./supabase/functions/my-function/index.ts
command, one is able to test and run the function.To Reproduce
index.ts
inside the./supabase/functions
dir../supabase/lib/cors.ts
.cors.ts
inside theindex.ts
file.import_map.json
relative to the location of the import_map.json filesupabase functions serve my-function
Expected behavior
The local edge function runs successfully as it does in deno.
Screenshots
N/A
System information
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: