Ohm
Ohm
DDeno
Created by Ohm on 9/13/2023 in #help
API hooks during restart for deno run --watch
After a week of learning more things, I've learned that development mode for Deno fresh does auto-refresh the web page ([1]). I've observed that it does so via SSE and esbuild as well. It also takes advantage of things like ETags (and If-None-Match header) for static resources. Neat! I also noticed that whenever the local development server becomes unhealthy (e.g. upon quitting the deno task start process, or upon saving during incomplete / typoed / buggy code), the EventSource within Chrome seems to indefinitely retry the connection every 100ms or so. That goes against what I initially (and likely mistakenly) understood from the processing model of SSE ([2]). Not a big deal for local development, and perhaps something I'll depend on for now! [1] https://fresh.deno.dev/docs/getting-started/running-locally#:~:text=updates%20automatically [2] https://html.spec.whatwg.org/multipage/server-sent-events.html#sse-processing-model
8 replies
DDeno
Created by Ohm on 9/13/2023 in #help
API hooks during restart for deno run --watch
Gotcha. Thanks for sharing this paradigm! I’ll keep an open mind about this idea for when my server development code no longer changes heavily and whenever my focus transitions primarily to cross-browser client code
8 replies
DDeno
Created by Ohm on 9/13/2023 in #help
API hooks during restart for deno run --watch
Wow, this is a totally different approach and neat approach! If I understand it well enough, the major advantage over puppeteer (for a use case as simple as programmatically reloading-on-demand) is that it is more inherently supported across more browsers. Additionally, it appears less reliant on external libraries (namely: avoiding a dependency on puppeteer inside an instrumented helper script). (Though, I imagine this is not considered a dealbreaker for scenarios like manual testing.) I imagine the optimization to avoid reloads on pure CSS can be instrumented with puppeteer with similar complexity. I don’t know enough about SSE, so I don’t know how robust it will be when I allow the server app process to restart after saving server source code changes. I have not tested it out myself, so I can only speculate behavior in the worst case (upon glancing at the EventSource spec). The only situation I speculate being weary about is when I might accidentally save server code that compiles but fails to reach a healthy server, in which case I imagine that the browser would retry the connection for a couple times before deeming the server as unhealthy and closing the EventSource until the developer manually refreshes the browser.
8 replies