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

Invalid file path on startup for relative imported modules / files #148

Open
2 tasks done
Unkn0wn0x opened this issue Jul 28, 2023 · 7 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Unkn0wn0x
Copy link

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

I'm running the supabase edge-runtime in a self hosted environment. Since the upgrade from supabase/edge-runtime:v1.5.2 to the latest available version supabase/edge-runtime:v1.7.2 I'm getting the following error on the container startup:

Failed to load module: "file:///home/deno/functions/_shared/headers.ts" - Invalid file path.
  Specifier: file:///home/deno/functions/_shared/headers.ts
CPU time used: 13ms
Error: worker boot error

The setup is exactly the same as described in the example here.

It works as expected on supabase/edge-runtime:v1.6.0.

I'm mounting the functions directory as described in the docker example file here.

volumes:
      - ./volumes/functions:/home/deno/functions:Z

It seems like there is a / (slash) to much (3 instead of 2) in the file path where it tries to load the file.

Expected behavior

The local file / module import works as expected.

Currently:
file:///home/deno/functions/_shared/headers.ts

Should be / correct:
file://home/deno/functions/_shared/headers.ts

@Unkn0wn0x Unkn0wn0x added the bug Something isn't working label Jul 28, 2023
@laktek
Copy link
Contributor

laktek commented Aug 2, 2023

Can you upgrade to edge-runtime 1.8.2 and see if it fixes the issue?

@Unkn0wn0x
Copy link
Author

Unkn0wn0x commented Aug 5, 2023

Checked on version 1.8.2 and 1.9.0 (latest available for now) and still the same error on container startup:

Failed to load module: "file:///home/deno/functions/_shared/headers.ts" - Invalid file path.
  Specifier: file:///home/deno/functions/_shared/headers.ts

Tried to import the headers.ts with and without the extension (.ts).

The latest stable and for me working version is 1.6.0.

@sandeepone
Copy link

its working for us @1.9.0. Please update the main.ts
3288f8b#diff-e0cd37e1a18fe936ed378c94a5b2ceda7cd50465278766753934c8554b05a120L58

@Unkn0wn0x
Copy link
Author

Thanks for your response, still getting the same error @1.9.0.

I digged a little bit through the latest commits and versions and noticed that everything works fine until @1.6.2 and breaks at @1.6.3.

There I found this commit / change which is related to @1.6.3:

Seems related to this commit, can you have a look at it?

Regardless if I keep the customModuleRoot set to '', null or without the setting at all.

@laktek
Copy link
Contributor

laktek commented Aug 8, 2023

Can you share your main/index.ts? If you remove customModuleRoot from createWorker options, you shouldn't get this error.

@Unkn0wn0x
Copy link
Author

Unkn0wn0x commented Aug 20, 2023

The part for the workers is exactly the same as described in the example:

--- EDIT ---

I'm pretty sure to know where's the error. As already mentioned, it stopped to work for me with v1.6.3, here are the changes:

If digged a little bit more into the changes and found especially this change, which also gives me the exact error on container startup:

This check I'm referring to:

As far as I understand (I'm not familiar with Rust) the functions checks, if a locally imported file / file path does not start with &self.root_path (should be the current directory) it throws the error I'm getting.

Now I don't know what the values for file_path and &self.root_path are. I assume, that the file_path is holding the value file:///home/deno/functions/_shared/headers.ts. Could it be by any chance, that the &self.root_path does not start with file:// and the check breaks? For example:

  • file_path= file:///home/deno/functions/_shared/headers.ts
  • &self.root_path = /home/deno/functions/

As far as I understand, the file:// prefix should be removed from the file_path before checking against the value of &self.root_path?

Thanks so far.

@Unkn0wn0x
Copy link
Author

Are there any updates on this topic?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants