Skip to content

Commit

Permalink
feat: add server debugging article (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxshady authored Mar 14, 2024
1 parent 1a3baf2 commit bf4425c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions docs/articles/debugging-server-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Debugging server code

alt:V allows you to debug your server-side code just like you would do in [NodeJS](https://nodejs.org/en/learn/getting-started/debugging).

## How?

1. Enable inspector in `resource.toml`.

```toml
type = 'js'
main = 'main.js'

[inspector]
# You can also specify host and port if needed
# (127.0.0.1:9229 by default)
# host = '127.0.0.1'
# port = '9999'
```

2. Add NodeJS interval with 0 delay.

```js
setInterval(() => {}, 0)
```

3. Now you should be able to connect to inspector via Chrome DevTools for example:

1. Open any webpage in Chrome
2. Press f12 to open console
3. Click on NodeJS icon

Video tutorial:

<iframe width="1280" height="720" src="https://www.youtube-nocookie.com/embed/F7mzNho5un8" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
3 changes: 2 additions & 1 deletion docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
href: vehicle/train-api.md
- name: Workers
href: workers.md

- name: Debugging server code
href: debugging-server-code.md

0 comments on commit bf4425c

Please sign in to comment.