Visual Studio Code Wrangler Debug Configuration #4174
JustinGrote
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
You can use this to attach and debug Cloudflare Workers written in Typescript using the new
workerd
local process that ships in Wrangler v3. Put it in yourlaunch.json
file for the project or your settings.jsonlaunch
setting.Warning
Until #4127 lands, you must have your repository on the C: drive on windows for this to work, otherwise it will silently fail if you have it on for instance D: when using DevDrive.
Task and Attach Method (Recommended)
Launch Method
Now when you visit a site, you should be able to hit typescript breakpoints set in your files:
Test Debugging
For Wrangler v3, while you can use
miniflare
, its lack of step-through debugging is a real pain when troubleshooting. Instead, I recommend using theTask and Attach Method
above to get your wrangler dev going and attached, and then adding something like this to your tests:Basically, if you have your
wrangler dev
running, your tests will use that, and step through debugging will work as long as you have it running. If you don't, it will spin up a temporaryworkerd
for that purpose.You can also use
miniflare v3
, which usesworkerd
on the backend, if you need to test some more advanced or nuanced scenarios, however this does not have step-through debugging and does not have native typescript support (you'll have to bundle/compile yourself rather than use wranglerd)https://github.com/cloudflare/miniflare/blob/v3.20231002.1/packages/miniflare/README.md
Beta Was this translation helpful? Give feedback.
All reactions