-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a7404b
commit 4ce50a7
Showing
8 changed files
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
``` | ||
|
||
|
@@ -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 | ||
``` | ||
|
||
|
@@ -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 | ||
... | ||
|
@@ -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/ | ||
``` | ||
|
||
|
@@ -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 | ||
``` | ||
|
||
|
@@ -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 | ||
``` | ||
|
||
|
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes