Skip to content

Updated

Debug Edge Functions locally

Debug your Edge Functions locally using Chrome DevTools for breakpoint debugging and code inspection.

Debug your Edge Functions on your machine in Chrome DevTools, with breakpoints and code inspection.

Overview

Supabase CLI v1.171.0 or later supports debugging Edge Functions via the v8 inspector protocol, allowing for debugging via Chrome DevTools and other Chromium-based browsers.

Inspect with Chrome Developer Tools

To debug a function, serve it in inspect mode, connect DevTools, then send a request. This takes two phases.

1. Serve your function and connect DevTools

To serve your functions in inspect mode and connect Chrome DevTools to them:

  1. Serve your functions in inspect mode. This sets a breakpoint at the first line to pause script execution before any code runs.
    supabase functions serve --inspect-mode brk
  2. In your Chrome browser, go to chrome://inspect.
  3. Click Configure... to the right of the Discover network targets checkbox.
  4. In the Target discovery settings dialog box that opens, enter 127.0.0.1:8083 in the blank space and click Done to close the dialog.
  5. Click Open dedicated DevTools for Node to complete the preparation for debugging. The opened DevTools window now listens to any incoming requests to edge-runtime.

Chrome DevTools is now configured and ready to debug your functions.

2. Send a request and debug it

To pause on a request and inspect your function's execution:

  1. Send a request to your function running locally, e.g. via curl or Postman. The DevTools window now pauses script execution at the first line.
  2. In the Sources tab, go to file:// > home/deno/functions/<your-function-name>/index.ts.
  3. Use the DevTools to set breakpoints and inspect the execution of your Edge Function.

Chrome DevTools paused on a breakpoint in an Edge Function's index.ts. The Sources file tree is on the left, the code with an inspected array of results is in the middle, and the Scope panel is on the right.

Next steps

To keep building and testing your functions locally, see these pages: