srcbookdev / srcbook

TypeScript-centric app development platform
https://srcbook.com
Apache License 2.0
2.58k stars 101 forks source link

Improve logs and preview server behavior #404

Closed benjreinhart closed 1 month ago

benjreinhart commented 1 month ago

When playing around with the app, I saw some vite dev server behavior I wasn't sure on and then the logs (somewhat lacking) made it more confusing to me. I wasn't sure if we had tried to re-boot it, or what. I also didn't see anything about it shutting down. Then I noticed some websocket events were firing multiple times.

This PR:

  1. Removes the duplicated websocket events
  2. Fixes a bug where we are replying to a specific connection rather than broadcasting during the lifetime of a running preview server. This has a couple issues:
    1. That connection may no longer exist (e.g., user refreshes page)
    2. This would only forward output to one client. If I have multiple tabs open, I wouldn't see the output in the other tab(s).
  3. Adds consistent logging for the preview server states (booting, running, stopping)
  4. Cleans the logs. Adds a "srcbook" source to differentiate from vite or other output.

Initial boot

Screenshot 2024-10-21 at 9 05 14 PM

Stopped the server which caused it to auto-restart

Screenshot 2024-10-21 at 9 05 43 PM
nichochar commented 1 month ago

Thanks for all the touch ups!