mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
Closes DOCS-1614 ## Problem This PR is to apply the template to top-five low-hanging fruit pages -- ones that nearly match the template already and do not need to break out new topics. This PR also tests the template to see that it is working as expected. ## Solution Apply the How-to Template to 5 how-to pages. ## Preview links | Site | Live | Preview | Search for | | --- | --- | --- | --- | | Docs | [/docs/guides/storage/analytics/creating-analytics-buckets](https://supabase.com/docs/guides/storage/analytics/creating-analytics-buckets) | [/docs/guides/storage/analytics/creating-analytics-buckets](https://docs-git-docs-howto-rework-easy-pages-supabase.vercel.app/docs/guides/storage/analytics/creating-analytics-buckets) | Create an analytics bucket | | Docs | [/docs/guides/functions/debugging-tools](https://supabase.com/docs/guides/functions/debugging-tools) | [/docs/guides/functions/debugging-tools](https://docs-git-docs-howto-rework-easy-pages-supabase.vercel.app/docs/guides/functions/debugging-tools) | Debug Edge Functions locally | | Docs | [/docs/guides/queues/consuming-messages-with-edge-functions](https://supabase.com/docs/guides/queues/consuming-messages-with-edge-functions) | [/docs/guides/queues/consuming-messages-with-edge-functions](https://docs-git-docs-howto-rework-easy-pages-supabase.vercel.app/docs/guides/queues/consuming-messages-with-edge-functions) | Consume queue messages | | Docs | [/docs/guides/database/postgres/setup-replication-external](https://supabase.com/docs/guides/database/postgres/setup-replication-external) | [/docs/guides/database/postgres/setup-replication-external](https://docs-git-docs-howto-rework-easy-pages-supabase.vercel.app/docs/guides/database/postgres/setup-replication-external) | Replicate to an external Postgres | | Docs | [/docs/guides/security/rotate-leaked-api-keys](https://supabase.com/docs/guides/security/rotate-leaked-api-keys) | [/docs/guides/security/rotate-leaked-api-keys](https://docs-git-docs-howto-rework-easy-pages-supabase.vercel.app/docs/guides/security/rotate-leaked-api-keys) | Rotate a leaked API key | ## Review instructions 1. Open the live and preview links for each page side by side. 2. Check that each page opens with a value statement and ends with Next steps. 3. Check that the code blocks and the Dashboard steps match the live page. 4. On the debugging page, check that the steps run in order across the two phases. 5. On the replication page, check that the code blocks and notes render under the right steps and the numbering runs 1 to 5. 6. On the rotate page, check that the "Retire the compromised key" link in Prerequisites still jumps to its heading. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
51 lines
2.8 KiB
Plaintext
51 lines
2.8 KiB
Plaintext
---
|
|
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/<your-function-name>/index.ts`.
|
|
3. Use the DevTools to set breakpoints and inspect the execution of your Edge Function.
|
|
|
|

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