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

Functions debugging broken #2646

Closed daniel-sc closed 2 months ago

daniel-sc commented 2 months ago

Describe the bug Using v1.191.3 the debugging of functions fails on Windows. See error below. This is/was working with v1.191.0.

To Reproduce Steps to reproduce the behavior:

  1. run npx supabase@latest functions serve --inspect-mode brk
  2. make a curl request
  3. See error "thread '' panicked ..."

Expected behavior It should not fail and debugging should be possible.

Screenshots

user@machine:/mnt/c/dev/projekte/auto-l10n$ RUST_BACKTRACE=1 npx supabase@latest functions serve --inspect-mode brk
Setting up Edge Functions runtime...
Serving functions on http://127.0.0.1:54321/functions/v1/<function-name>
Using supabase-edge-runtime-1.56.1 (compatible with Deno v1.43.0)       
serving the request with /mnt/c/dev/projekte/auto-l10n/supabase/functions/translate-xlf2
Debugger listening on ws://0.0.0.0:8083/ws/ff2ed703-91a5-4e1c-85fc-4fe8bf6ecf96
Visit chrome://inspect to connect to the debugger.
Worker is waiting for debugger to connect.
thread '<unnamed>' panicked at /usr/local/cargo/git/checkouts/deno_core-1aa117f39acc86a9/6323369/core/inspector.rs:367:16:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to send request to user worker: request has been cancelled by supervisor
error in user worker connection: error writing a body to connection
user worker failed to respond: request has been cancelled by supervisor
WorkerRequestCancelled: request has been cancelled by supervisor
    at async Promise.allSettled (index 1)
    at async UserWorker.fetch (ext:sb_user_workers/user_workers.js:73:61)
    at async Object.handler (file:///root/index.ts:163:14)
    at async respond (ext:sb_core_main_js/js/http.js:163:14) {
  name: "WorkerRequestCancelled"

System information Rerun the failing command with --create-ticket flag. => This does give the same output as without the --create-ticket flag!

Additional context If applicable, add any other context about the problem here.

sweatybridge commented 2 months ago

cc @nyannyacha as it seems related to the edge runtime upgrade to 1.56.1 https://github.com/supabase/cli/releases/tag/v1.191.1

nyannyacha commented 2 months ago

I'll take a look

nyannyacha commented 2 months ago

It doesn't look like the inspector is causing panic for all user scripts.

Hello @daniel-sc 😁 Can you provide some reproducible code?

daniel-sc commented 2 months ago

@nyannyacha the following function reproduces this:

import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { XmlDocument } from "npm:xmldoc@~1.3.0";

Deno.serve(async (req) => {
  console.log("Request received");

  const doc = new XmlDocument("requestBody");

  return new Response("done");
});