Skip to content

Commit

Permalink
refactor: inspect/debugging as useInspector
Browse files Browse the repository at this point in the history
This PR rewrites the logic for establishing a connection with the debugging socket, and adds some enhancements along the way.  Part of solving #188. Some highlights -

- I've installed `"devtools-protocol`, a convenient package that has the static types for the devtools protocol (duh) autogenerated from chrome's devtools codebase.
- We now log messages and exceptions into the terminal directly, so you don't have to open devtools to see those messages.
- Messages are now buffered until a devtools instance connects, so you won't lose any messages while devtools isn't connected.
- We don't lose the connection on making changes to the worker, removing the need for the kludgy hack on the devtools side (where we refresh the whole page when there's a change)

Some things that I still have to do, and will do so in followup PRs -
- clear the console whenever we make a change to the worker
- stay connected when we shift between local/remote mode
- eventually, move to using the devtools hosted at cloudflareworkers.com.
  • Loading branch information
threepointone committed Jan 6, 2022
1 parent 19d3833 commit 16a1298
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 481 deletions.
10 changes: 10 additions & 0 deletions .changeset/slimy-suits-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"wrangler": patch
---

Refactor inspection/debugging code -

- I've installed devtools-protocol, a convenient package that has the static types for the devtools protocol (duh) autogenerated from chrome's devtools codebase.
- We now log messages and exceptions into the terminal directly, so you don't have to open devtools to see those messages.
- Messages are now buffered until a devtools instance connects, so you won't lose any messages while devtools isn't connected.
- We don't lose the connection on making changes to the worker, removing the need for the kludgy hack on the devtools side (where we refresh the whole page when there's a change)
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"chokidar": "^3.5.2",
"clipboardy": "^3.0.0",
"command-exists": "^1.2.9",
"devtools-protocol": "^0.0.955664",
"execa": "^6.0.0",
"faye-websocket": "^0.11.4",
"finalhandler": "^1.1.2",
Expand Down
Loading

0 comments on commit 16a1298

Please sign in to comment.