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
Use Workerd for local development #1184
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this, amazing work!
Using the Chrome dev tools protocol to interact with workerd
is very clever and not something I had looked into myself. It does lead to quite an amount of complexity, and I'm finding the code a little bit hard to read. I can see the value it adds over miniflare's own logging, but did experience some volatility at times with Miniflare crashing with non-descript errors (nothing I can replicate though).
Do you think this is a viable route? Or should we aim to modify miniflare to allow for these use-cases without having to mimic Wrangler's methods?
@vincentezw Thanks for the review!
Miniflare/workerd's logging is kind of awkward and not complete, so we can't rely on that. For example, it does not show stack traces from errors. Also, every message is colored and mixed with other cryptic information about C++. It only shows stuff when using I've seen some unexpected crashing from Miniflare as well but I think it wasn't related to dev tools. Something to debug deeper before releasing for sure.
As mentioned above, I don't think we can do anything else with logs apart from using dev tools, unless we want to jump into workerd direclty (and even like that, it would probably take a long time to be reviewed and released). Wrangler uses this method by default when running workers locally so it's probably good enough. |
Looking good! All skeleton routes seem to be working ok. The only thing I noticed is a few instances of this log (maybe is my connection?):
|
@@ -35,7 +36,7 @@ export async function runPreview({ | |||
|
|||
const miniOxygen = await startMiniOxygen({ | |||
root, | |||
port, | |||
port: await findPort(port), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤟🏼
I think an unstable release sounds very reasonable. fwiw the difference in size between miniflare2-3 is rather small (280k vs 1.8m) but mini-oxygen is quite bloated as a dependency). |
I'm assuming you're using Bundlephobia to check the sizes but I think that service is not super accurate. The workerd binary alone is 60+ MB on Mac and ~75 MB on Linux I think. Using a more accurate tool:
Therefore, maybe we could install |
@juanpprieto I think the connection lost and promise rejection errors are due to the connection getting cancelled from the browser. It happens easily when navigating quickly between pages, so before a loader request can finish, a new one starts so the previous is cancelled. Or a prefetch request that doesn't finish before navigating, so it gets cancelled I guess the question is, should these be showing up in the logs. Are devs going to get confused and freak out? |
Waiting for the next release of Miniflare which drops a dependency that can make installation times considerably slower. |
This removes the@shopifiy/mini-oxygen
dependency, which relies on Miniflare v2, and directly relies on Miniflare v3 + Workerd for local development.Add
--worker-unstable
flag todev
andpreview
commands to run the app on Workerd (Miniflare v3).Without this flag, it runs in a Node.js sandbox (MiniOxygen/Miniflare v2).
Part of the logging logic is taken from Wrangler: it establishes a WS connection to DevTools and listens for events to log messages and errors.
🎩