Fix bootstrap.js crash from premature @actions/core static import#144
Closed
Fix bootstrap.js crash from premature @actions/core static import#144
Conversation
Root cause: PR #143 added `import * as core from '@actions/core'` as a top-level static import. Since node_modules isn't pre-installed, Node.js fails to resolve this import before any code (including npm ci) runs. Fix: Replace the static top-level import with a dynamic import inside the `finally` block where node_modules is guaranteed to exist. For the npm ci failure case, use console.error since @actions/core isn't available yet. Co-authored-by: JoyceZhu <6251669+JoyceZhu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions workflow Test (sites/site-with-errors)
Fix bootstrap.js crash from premature @actions/core static import
Feb 24, 2026
JoyceZhu
approved these changes
Feb 24, 2026
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.
All four
bootstrap.jsfiles gained a top-levelimport * as core from '@actions/core'to enable richer error logging. Sincenode_modulesis installed at runtime (vianpm ci), Node.js fails to resolve this ESM static import before any bootstrap logic runs, crashing the action immediately.Changes
import * as core from '@actions/core'withconst core = await import('@actions/core')as the first statement in thefinallyblock, wherenode_modulesis guaranteed to existnpm cifailure path:console.erroris used here since@actions/coreis unavailable when installation itself fails;core.setFailed()is preserved for thenpm run buildfailure path wherenode_modulesis present{spawn}, single-param arrow functions, trailing commas)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.