Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for debugging #74

Closed
jamesopstad opened this issue Nov 21, 2024 · 3 comments
Closed

Improve support for debugging #74

jamesopstad opened this issue Nov 21, 2024 · 3 comments
Assignees

Comments

@jamesopstad
Copy link
Contributor

jamesopstad commented Nov 21, 2024

Confirm that VSCode can use breakpoints in Workers. Document how to enable this.

@dario-piotrowicz
Copy link
Contributor

dario-piotrowicz commented Dec 14, 2024

Quick update on the situation

I've started looking at the debugging situation here

I've applied (to the main code currently at 91ca74) an inspectorPort to the getDevMiniflareOptions and getPreviewMiniflareOptions methods:
Screenshot 2024-12-14 at 18 39 59

And slightly modified the worker playground app:
Screenshot 2024-12-14 at 19 11 22

When I run the application (pnpm dev) I can successfully connect my vscode (using the configuration mentioned in our documentation) to the workerd process inspector:
Screenshot 2024-12-14 at 18 47 16

But strangely vscode does not then stop at the debugger statement I added, so this is currently not working as expected (I am pretty sure that this at some point was working)1.

Using chrome I can however go to chrome://inspect and find various workers I can connect to:
Screenshot 2024-12-14 at 18 52 18

Among those I can select the user one workerd: worker core:user:worker and then the debugger statement is correctly encountered, I can also step through, see typescript original code, see the various variable values, etc... everything seems to be working as expected here:
Screenshot 2024-12-14 at 19 10 49

Footnotes

  1. I double checked and wrangler (which uses the same version of miniflare we do: 3.20241205.0) doesn't seem to have any issue with attaching vscode to the worker and stopping at a debugger statement, suggesting that something is wrong on our side:
    wrangler dev debugger

@dario-piotrowicz
Copy link
Contributor

The same applies for the multi-worker app:
Screenshot 2024-12-14 at 22 07 55

Naturally with a few more workers to chose from in the chrome inspect page:
Screenshot 2024-12-14 at 22 02 10

Warning

When I started debugging the multi-worker app I encountered some connection lost errors, after restarting pnpm dev they seem to have disappeared, but I think there's an issue around this, I'll need to keep an eye out for this

@jamesopstad
Copy link
Contributor Author

Moved to cloudflare/workers-sdk#7852.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants