Debugging and editor setup

Configure VS Code and deno lsp, debug with --inspect breakpoints, and trace permission and leak issues

VS Code extension

Install the official extension denoland.vscode-deno, then run Deno: Initialize Workspace Configuration from the command palette. It writes this into your workspace .vscode/settings.json:

{
  "deno.enable": true
}
  • Enable per workspace only, never in user settings — otherwise every project is treated as a Deno project.
  • Once enabled, the extension hands off to the Deno language server and mutes VS Code's built-in TS/JS diagnostics.
  • In mixed repositories, use deno.enablePaths to activate Deno only in subfolders (e.g. ./supabase/functions).

Other editors attach to the same language server over LSP:

deno lsp

When something misbehaves, check Deno: Language Server Status in the command palette to confirm the active configuration first.

Inspector breakpoints

Deno speaks the V8 Inspector protocol, with three flags for three startup modes:

FlagBehavior
--inspectStarts the debug server; code runs immediately
--inspect-waitWaits for a debugger to attach before running
--inspect-brkWaits, then breaks on the first line

The default address is 127.0.0.1:9229. Open chrome://inspect in a Chromium-based browser and click Inspect next to the target to set breakpoints and step through code; source maps show your original TypeScript.

VS Code connects with an attach configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to dev server",
      "type": "node",
      "request": "attach",
      "port": 9229
    }
  ]
}
deno run --inspect-wait --allow-net main.ts

Tracing permissions and leaks

When a permission error's origin is unclear, ask the runtime for the triggering stack:

DENO_TRACE_PERMISSIONS=1 deno run main.ts

When tests report leaked resources or async ops, trace their source:

deno test --trace-leaks

--trace-leaks slows test execution down; remove it once the leak is found instead of leaving it in CI. Both are diagnostics only — their output points at the cause, it does not fix it.

Logging layers

  • During development, console.log / console.error write to stdout/stderr, which container platforms collect natively.
  • In production, emit structured JSON logs (one object per line with level, msg, requestId fields) instead of free text that needs regex parsing.
  • Turn on --log-level=debug for the Deno runtime's own diagnostics (module resolution, network, permission decisions), and turn it off once the problem is found; third-party library log levels are controlled by each library's own configuration and are out of this flag's reach.
  • Logs never contain secrets or personal data; see Environment variables and .env.

Official references: Debugging, VS Code, deno test.

Type to search all documentation.