cli icon indicating copy to clipboard operation
cli copied to clipboard

Issue with Supabase functions serve (Edge Functions)

Open shivamklr opened this issue 1 year ago • 0 comments

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:[email protected]';

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).

  • Ticket ID: [or provide the information manually below]
  • OS: Windows
  • Version of CLI: Using supabase-edge-runtime-1.33.5 (compatible with Deno v1.39.2
  • Versions of services:

       SERVICE IMAGE      │        LOCAL         │  LINKED
 ─────────────────────────┼──────────────────────┼────────────
   supabase/postgres      │ 15.1.1.13            │ 15.1.1.13
   supabase/gotrue        │ v2.132.3             │ v2.132.3
   postgrest/postgrest    │ v12.0.2              │ v12.0.2
   supabase/realtime      │ v2.25.50             │ -
   supabase/storage-api   │ v0.48.1              │ v0.48.1
   supabase/edge-runtime  │ v1.33.5              │ -
   supabase/studio        │ 20240101-8e4a094     │ -
   supabase/postgres-meta │ v0.75.0              │ -
   supabase/logflare      │ 1.4.0                │ -
   bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
   darthsim/imgproxy      │ v3.8.0               │ -

shivamklr avatar Feb 19 '24 12:02 shivamklr