--- id: 'functions-debugging-tools' title: 'Debug Edge Functions locally' description: 'Debug Edge Functions locally with Chrome DevTools: serve in inspect mode, attach DevTools, send a request, then set breakpoints to inspect your function.' subtitle: 'Debug your Edge Functions locally using Chrome DevTools for breakpoint debugging and code inspection.' tocVideo: 'sOrtcoKg5zQ' --- Debug your Edge Functions on your machine in Chrome DevTools, with breakpoints and code inspection. ## Overview Supabase CLI [v1.171.0](https://github.com/supabase/cli/releases/tag/v1.171.0) or later supports debugging Edge Functions via the v8 inspector protocol, allowing for debugging via [Chrome DevTools](https://developer.chrome.com/docs/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. ```bash 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//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.](/docs/img/guides/functions/debug-chrome-devtools.png) ## Next steps To keep building and testing your functions locally, see these pages: - [Development environment](/docs/guides/functions/development-environment): set up your editor and project structure for Edge Functions. - [Testing your Edge Functions](/docs/guides/functions/unit-test): write unit tests with Deno Test. - [Edge Functions logging](/docs/guides/functions/logging): read the logs for your functions.