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

Unexpected behaviour when importing another project using its mod.ts file #3093

Open
maximilian-hammerl opened this issue Feb 2, 2025 · 7 comments

Comments

@maximilian-hammerl
Copy link

maximilian-hammerl commented Feb 2, 2025

Describe the bug

We started using Deno workspaces recently and when we found it that Supabase edge functions do not yet support Deno workspaces (#3047), we worked around this issue by adding the workspace members to the imports like this:

{
  "imports": {
    ...
    "other_workspace_member_name/": "../path/to/workspace/member/",
    ...
  }
}

As the next step we wanted to just import the mod.ts files of the other workspace members:

{
  "imports": {
    ...
    "other_workspace_member_name": "../path/to/workspace/member/mod.ts",
    ...
  }
}

While we refactored our edge functions, we tested every edge functions after we adjusted its imports and everything worked as expected.
But as soon as we refactored the last edge functions, all edge functions always failed with the following error message:

Using supabase-edge-runtime-1.66.5 (compatible with Deno v1.45.2)
serving the request with supabase/functions/import-mod-ts
worker boot error: failed to create the graph: Module not found "file:///.../supabase-local-import-bug/another-project/file_a.ts".
    at file:///.../supabase-local-import-bug/another-project/mod.ts:1:15
worker boot error: failed to create the graph: Module not found "file:///Users/maximilianhammerl/Documents/Repositories/supabase-local-import-bug/another-project/file_a.ts".
    at file:///...supabase-local-import-bug/another-project/mod.ts:1:15
InvalidWorkerCreation: worker boot error: failed to create the graph: Module not found "file:///Users/maximilianhammerl/Documents/Repositories/supabase-local-import-bug/another-project/file_a.ts".
    at file:///.../supabase-local-import-bug/another-project/mod.ts:1:15
    at async UserWorker.create (ext:sb_user_workers/user_workers.js:139:15)
    at async Object.handler (file:///root/index.ts:157:22)
    at async respond (ext:sb_core_main_js/js/http.js:197:14) {
  name: "InvalidWorkerCreation"

To Reproduce

Repository with more details, examples and to how to reproduce: https://github.com/maximilian-hammerl/supabase-local-import-bug

Expected behavior

Imports of one edge functions should not affect other edge functions in any way.


I was not sure whether to open this issue here in the CLI repository or in the edge runtime repository. I decided for the CLI repository, as we use the edge runtime through the CLI.

@maximilian-hammerl
Copy link
Author

I added a GitHub action with 3 jobs which hopefully make the problem quite clear:


The mod-ts-and-relative-import job just calls both edge functions:

relative path test:
...
{"message":"Edge function with relative path import"}
----------
mod.ts test:
---
{"message":"Edge function with mod.ts import"}

Both edge functions respond successfully.


In the only-relative-import job the import-mod-ts edge functions is first removed, before the edge functions are called:

relative path test:
...
{"message":"Edge function with relative path import"}
----------
mod.ts test:
...
Function not found

As expected the only-relative-import edge function responds successfully, the import-mod-ts edge function is not found.


In the only-mod-ts job the import-relative-path edge functions is first removed, before the edge functions are called:

relative path test:
...
Function not found
----------
mod.ts test:
...
{"code":"BOOT_ERROR","message":"Worker failed to boot (please check logs)"}

As expected the only-relative-import edge functions is not found, but the import-mod-ts edge function fails, although the edge function was not modified in any way.

@sweatybridge
Copy link
Contributor

@nyannyacha fyi

@nyannyacha
Copy link
Contributor

nyannyacha commented Feb 3, 2025

I plan to check this thing in the Deno 2.1 upgrade.
And yes, the workspace feature is currently not supported.
FUNC-172

@maximilian-hammerl
Copy link
Author

maximilian-hammerl commented Feb 12, 2025

@sweatybridge, I just wanted to ask whether this problem is really related to Deno workspaces and whether it should be closed as a duplicate of the Deno workspaces issue.

Yes, it occurred when we tried this mod.ts import as an alternative to Deno workspaces, but as far as I am concerned importing something by their mod.ts file should work independent of Deno workspaces.

@sweatybridge sweatybridge reopened this Feb 12, 2025
@nyannyacha
Copy link
Contributor

Perhaps it's a docker volume mount issue?

I looked at https://github.com/maximilian-hammerl/supabase-local-import-bug and it refers to a folder higher than supabase folder.
not sure as I don't monitor the CLI repository often, but does the cli mount the parent folder?

@sweatybridge
Copy link
Contributor

@nyannyacha oh you are probably right. We do support parent directories but in a somewhat limited way. #2533 (comment)

We have released a fix for functions deploy but for local serving, this might still be an issue.

@nyannyacha
Copy link
Contributor

nyannyacha commented Feb 27, 2025

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

No branches or pull requests

3 participants