You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A Gutenberg site's dev server serves before npm run dev has rebuilt build/, so the first wp-admin load fails #488
On a Gutenberg site, Start dev server hands out the site URL while the build watcher is still wiping and regenerating build/. Opening wp-admin in the first ~20 seconds shows one of two failures, depending on the second you land on:
a red admin notice, Gutenberg development mode requires files to be built. Run npm install… (the plugin found no build/scripts/blocks, so it did not load lib/), or
a PHP fatal on any admin page: Call to undefined function gutenberg_override_style() in wp-content/plugins/gutenberg/lib/client-assets.php:148.
Reloading after the watcher prints Watching for changes fixes both. Nothing tells the contributor that, and this is the first thing they see after creating their first Gutenberg site.
Root cause. Starting the dev server starts the watcher first and hangs the server start off its readiness (startBuildWatch({ onReady }) in src/renderer/index.jsx). On a site that already has a build, readiness is immediate: startWatchProcess() runs and onReady() fires in the same tick. That is right for Core, whose grunt -- _watch touches nothing on start. Gutenberg's npm run dev is different: tools/build-scripts/dev.mjs runs clean.mjs --packages first, which removes build/ entirely, then rebuilds for about 20 s, and the generated PHP registries (build/build.php, build/styles.php, where gutenberg_override_style() is defined) are the last files written. Every request Playground serves in that window loads a complete lib/ against a missing or half-written build/.
The same window reopens whenever the watcher is started by hand while the server is up.
Step-by-step reproduction instructions
Create a Gutenberg site and let the wizard finish (clone, install, build). Build watcher stopped.
Click Start dev server.
As soon as the URL appears, click wp-admin.
Expected: the dashboard, with Gutenberg active. Actual: the notice or the fatal above, until about 20 s later.
Fix
Gate the server start on the watcher's real readiness when the target's watcher rebuilds on start. Gutenberg gives two signals: wp-build --watch prints Watching for changes once its initial build is done, and dev.mjs writes a .dev-ready marker at the checkout root at the same moment. Core keeps starting immediately. While the watcher rebuilds, the tab reads Build watcher (building) and the dev-server button stays on Starting…; a watcher that exits before it is ready never starts the server.
Operating system
macOS (Apple Silicon). Not platform specific.
App version
Trunk at 4dbfaff, unreleased (the Gutenberg target ships in v1.2.0). Part of #251.
Activity
[Fix] Hold the dev-server start in a tested queue, and treat a rebuil…
[Fix] Stop dev server no longer kills the build watch (#488)
[Fix] Ignore a replaced watcher run's late callbacks (#488)
[Fix] A stop we asked for is not a crash, and a crash does not kill t…
[Fix] Name each project's own source directory in the hint under the …
[Fix] Let the resumed build watch do the one rebuild after a Gutenber…
Put a site's server and build watch in the page header and the details (
[Fix] Wait for Gutenberg's watcher to finish its first build before t…