supabase / edge-runtime

A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.
MIT License
680 stars 62 forks source link

Unable to deploy edge function (with axios) after upgrading the CLI #302

Closed muezz closed 7 months ago

muezz commented 8 months ago

Describe the bug I upgraded Supabase CLI on my machine to the latest version and it does not allow me to deploy my edge function. This goes away if I remove axios as a dependancy.

To Reproduce Steps to reproduce the behavior:

  1. Create a new edge function
  2. Import axios from https://esm.sh/axios@1.6.7. I use import map but I doubt that has an effect here.
  3. Try deploying with supabase functions deploy my-func --no-verify-jwt
  4. See error

Expected behavior The edge function should deploy without any errors which it does if I remove the axios dependancy.

System information Rerun the failing command with --create-ticket flag.

laktek commented 7 months ago

@muezz I think if you use esm.sh's axios you need to also import the xhr as a polyfill. Try adding this import to the top of your function's source file.

import "https://deno.land/x/xhr@0.1.0/mod.ts";

You can try directly importing axios from npm: ie. import axios from "npm:axios@1.6.7"

That should work without needing any polyfills.

muezz commented 7 months ago

@laktek I actually ended up removing axios as a dependancy as I was in a hurry to deploy the functions. I will try it out when I need to use axios again.

If this is indeed not a bug and something that you have to do (I mean importing xhr), let me know and I will close this ticket.

laktek commented 7 months ago

yeah, our recommendation would be to use npm:axios if you need to use it.

I will close this issue since there's no fix needed from our end.