supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.07k stars 209 forks source link

Issue with Supabase functions serve (Edge Functions) #1963

Closed shivamklr closed 7 months ago

shivamklr commented 8 months ago

Describe the bug When using supabase functions serve I get the http status error code 546. From what I understand the npm package makes http requests to resolve the query. Not sure why runtime escapes the event loop. When I check the logs in cli I see this

image

To Reproduce Steps to reproduce the behavior:

  1. Create a new function
  2. import from npm
  3. run the function locally
  4. Make the http GET request
import { searchNews, SearchTimeType, SafeSearchType } from 'npm:duck-duck-scrape@2.2.5';

console.log("Hello from Functions!")

Deno.serve(async () => {
  try {
    const news = await searchNews('Latest news', { time: SearchTimeType.DAY, safeSearch: SafeSearchType.STRICT });
    return new Response(
      JSON.stringify(news),
      { headers: { "Content-Type": "application/json" } },
    );
  } catch (error) {
    return new Response(
      JSON.stringify({ error: error.message }),
      { headers: { "Content-Type": "application/json" } },
    );
  }
})

Expected behavior When I run the code directly using the Deno command. deno run --allow-net --allow-env .\functions\hello-world\index.ts. I get a status 200 response.

{
  "noResults": false,
  "vqd": "4-206730575884082559294778046947689285325",
  "results": [
    {
      "date": 1708336495,
      "excerpt": "The mother of Russian opposition leader Alexei Navalny on Monday was denied access to a morgue where his body was believed to be kept after his death in an Arctic penal colony, and Navalny's allies",
      "image": "https://www.bing.com/th?id=OVFT.-Z-MNOQeUeRuVkPrOTicBi&pid=News",
      "relativeTime": "2 hours ago",
      "syndicate": "Bing",
      "title": "Russian authorities extend a probe into Navalny's death as allies accuse officials of cover-up",
      "url": "https://www.msn.com/en-us/news/world/russian-authorities-extend-a-probe-into-navalnys-death-as-allies-accuse-officials-of-cover-up/ar-BB1ivv8m",
      "isOld": false
    },
  ]
}

Screenshots If applicable, add screenshots to help explain your problem.

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

michaelzoidl commented 7 months ago

Does anybody know if supabase functions have network restrictions? I've a similar problem with AWS Sdk which works with deno-run but throws an error when executed in the functions.

sweatybridge commented 7 months ago

@michaelzoidl I don't think we have specific network restrictions. Someone from functions team might be able to help if you can post a reproducible example in edge runtime repo.

Closing the original issue as resolved.