Skip to content

Run npm install asynchronously during apps init#4600

Open
jamesbroadhead wants to merge 1 commit intodatabricks:mainfrom
jamesbroadhead:jb/async-npm-install
Open

Run npm install asynchronously during apps init#4600
jamesbroadhead wants to merge 1 commit intodatabricks:mainfrom
jamesbroadhead:jb/async-npm-install

Conversation

@jamesbroadhead
Copy link

Changes

Start npm install in the background immediately after cloning the template, so it runs in parallel with the interactive prompts rather than blocking after all questions are answered.

  • Add StartNpmInstallAsync() to kick off npm ci in a goroutine, returning a channel for the result
  • In runCreate(), start async npm install in the cloned template directory right after template resolution
  • After template copy + plugin application, wait for the background install and move node_modules to the project directory
  • Initialize() skips npm install if node_modules already exists (from the async pre-install)
  • Falls back gracefully: if async install fails, cleans up and lets Initialize() retry synchronously

Why

npm install is often the slowest step of databricks apps init. It currently runs sequentially after all interactive prompts and template copying. Since npm only needs package.json/package-lock.json (which exist in the cloned template), it can run in parallel with the user answering questions, reducing perceived wait time significantly.

Tests

  • TestStartNpmInstallAsyncReturnsChannel — verifies async function returns a usable channel
  • TestInitializeSkipsNpmInstallWhenNodeModulesExists — verifies Initialize skips npm when node_modules pre-exists
  • TestFindTemplateProjectDir (4 subtests) — verifies template project directory detection
  • All existing tests pass

Start npm install in the background immediately after cloning the template,
so it runs in parallel with the interactive prompts. This reduces total
init time by overlapping the (often slow) npm install with the time the
user spends answering questions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jamesbroadhead jamesbroadhead requested a review from a team as a code owner February 25, 2026 21:45
@github-actions
Copy link

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 4600
  • Commit SHA: ce33866da1619550c7ebdf27bb0439876a8db4a7

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant