Wait for index.html before copying admin static_root during dev#7305
Draft
MitchLillie wants to merge 1 commit intomainfrom
Draft
Wait for index.html before copying admin static_root during dev#7305MitchLillie wants to merge 1 commit intomainfrom
MitchLillie wants to merge 1 commit intomainfrom
Conversation
When running 'shopify app dev' immediately after 'shopify app init', there's a race condition where the web build process hasn't completed before the admin extension tries to copy files from static_root. This causes the dev session to fail with 'index.html must be present in the bundle' error. This fix adds a new 'wait_for_file' build step that: - Waits up to 60 seconds for index.html to appear in static_root - Polls every 500ms until the file exists - Only waits if static_root is configured - Succeeds immediately if the file already exists The wait step runs before the include_assets step in the admin extension's build pipeline, ensuring the files are ready before copying. Fixes: shop/issues-admin-extensibility#2411
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR adds a new
wait_for_filebuild step that waits forindex.htmlto exist in the admin extension'sstatic_rootdirectory before copying files.Why
Fixes https://github.com/shop/issues-admin-extensibility/issues/2411
When running
shopify app devimmediately aftershopify app init, there's a race condition where the web build process (which producesdist/index.html) hasn't completed before the admin extension tries to copy files fromstatic_root. This causes the dev session to fail with:How
New
wait_for_filebuild step (wait-for-file-step.ts):Updated admin extension specification (
admin.ts):wait_for_filestep before theinclude_assetsstepindex.htmlin the directory specified byadmin.static_rootTesting
wait_for_filestepTophatting Instructions
Prerequisites
Steps to reproduce the issue (before fix)
Create a new extension-only app:
HOSTED_APPS=1 pnpm shopify app init --name test-fix-index-html --path="$HOME/tmp"Immediately run dev:
HOSTED_APPS=1 pnpm shopify app dev --path="$HOME/tmp/test-fix-index-html"Expected (before fix): You should see an error like:
Steps to verify the fix
Create a new extension-only app:
HOSTED_APPS=1 pnpm shopify app init --name test-fix-index-html --path="$HOME/tmp"Immediately run dev:
HOSTED_APPS=1 pnpm shopify app dev --path="$HOME/tmp/test-fix-index-html"Expected (with fix):
Waiting for 'index.html' in './dist'...Found 'index.html' in './dist' (waited X.Xs)Additional scenarios to test
File already exists: If you run
pnpm buildin the app directory beforeshopify app dev, it should proceed immediately without waiting.Timeout behavior: If the build process fails and the file never appears, you should see a clear timeout error after 60 seconds:
No static_root configured: If the app doesn't have
admin.static_rootconfigured, the wait step should be skipped silently.