Skip to content

Commit

Permalink
moving debugging over (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisjofrank committed Aug 22, 2024
1 parent 3a7404b commit 4ce50a7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions runtime/_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const sidebar = [
items: [
"/runtime/fundamentals/ts_support/",
"/runtime/fundamentals/permissions/",
"/runtime/fundamentals/debugging/",
],
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: "Debugging Your Code"
oldUrl: /runtime/manual/getting_started/debugging_your_code/
oldUrl:
- /runtime/manual/getting_started/debugging_your_code/
- /runtime/manual/basics/debugging_your_code/
---

Deno supports the [V8 Inspector Protocol](https://v8.dev/docs/inspector) used by
Expand All @@ -18,22 +20,26 @@ for example Chrome DevTools. Visit `chrome://inspect` in a Chromium derived
browser to connect Deno to the inspector server. This allows you to inspect your
code, add breakpoints, and step through your code.

```shell
```sh
deno run --inspect your_script.ts
```

> ⚠️ If you use the `--inspect` flag, the code will start executing immediately.
> If your program is short, you might not have enough time to connect the
> debugger before the program finishes execution. In such cases, try running
> with `--inspect-wait` or `--inspect-brk` flag instead, or add a timeout at the
> end of your code.
:::note

If you use the `--inspect` flag, the code will start executing immediately. If
your program is short, you might not have enough time to connect the debugger
before the program finishes execution. In such cases, try running with
`--inspect-wait` or `--inspect-brk` flag instead, or add a timeout at the end of
your code.

:::

## --inspect-wait

Before running the code, the `--inspect-wait` flag will pause execution until a
debugger is attached.

```shell
```sh
deno run --inspect-wait your_script.ts
```

Expand All @@ -45,7 +51,7 @@ additional breakpoints or evaluate expressions before resuming execution. **This
is the most commonly used inspect flag**. JetBrains and VSCode IDEs use this
flag by default.

```shell
```sh
deno run --inspect-brk your_script.ts
```

Expand All @@ -57,7 +63,7 @@ server.

Use the `--inspect-brk` flag to break execution on the first line:

```shell
```sh
$ deno run --inspect-brk --allow-read --allow-net jsr:@std/[email protected]/file-server
Debugger listening on ws://127.0.0.1:9229/ws/1e82c406-85a9-44ab-86b6-7341583480b1
...
Expand Down Expand Up @@ -102,7 +108,7 @@ button to do so. You might even need to hit it twice!

Once our script is running, try send a request and inspect it in Devtools:

```console
```sh
curl http://0.0.0.0:4507/
```

Expand Down Expand Up @@ -140,7 +146,7 @@ If you're having trouble connecting to the inspector, you can use the
will show you information like module resolution, network requests, and other
permission checks.

```shell
```sh
deno run --inspect-brk --log-level=debug your_script.ts
```

Expand All @@ -152,7 +158,7 @@ networking, and timers to JavaScript. The `--strace-ops` flag will print out all
ops that are being executed by Deno when a program is run along with their
timings.

```shell
```sh
deno run --strace-ops your_script.ts
```

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 4ce50a7

Please sign in to comment.