Skip to content

Restart a workspace application that has only a start script when the checkout changes - #22

Merged
csandanov merged 1 commit into
masterfrom
feature/workspace-node-watch
Oct 8, 2026
Merged

csandanov merged 1 commit into
masterfrom
feature/workspace-node-watch

Conversation

@csandanov

Copy link
Copy Markdown
Member

In a development workspace, a Node.js application whose package has only a start script was started once. After a change to the code you had to restart the container to see it.

workspace-node start now watches the checkout for such a package: when a file changes, it stops the application and starts it again, in the same container.

Behavior

  • A package with a dev script is run as before: a dev script watches the files itself.
  • A package with only a start script is run under the watcher. Files are polled every WORKSPACE_POLL_INTERVAL milliseconds (1000 by default), because file events don't reach a shared volume.
  • Not watched: node_modules, .git, .wodby-workspace, .pnpm-store, .next, dist, build and coverage.
  • The script's processes run in a session of their own, so stopping reaches the application the package manager started.
  • An application that ends by itself still ends the container with its exit code. Stopping the container stops the application at once; one that ignores the signal is killed after ten seconds.
  • WORKSPACE_NODE_WATCH=0 turns the watcher off, and WORKSPACE_NODE_COMMAND is run as it is.

Validation

  • tests/workspace-reload.sh, which tests/run.sh already runs for development images, has new cases. Run against wodby/node:24-dev-r5 with this script: the Vite and Next.js cases still pass; for a start script a second container's edit was served by the same container with one application process left, the container stopped in under ten seconds with exit code 143, an application that exited took the container with it, and neither WORKSPACE_NODE_WATCH=0 nor a dev script got the watcher.
  • tests/workspace-runtime.sh passes in the same image.
  • Tried with npm only, not with pnpm or yarn, and not on a multi-node cluster with a network volume.

… checkout changes

In a development workspace workspace-node start runs the package's dev
script, which watches the files itself, or its start script, which runs
the application once. With only a start script a change to the code was
served only after the container was restarted.

workspace-node now watches the checkout for a start script. When a file
changes it stops the application and starts it again, in the same
container. Files are polled, because file events don't reach a shared
volume; installed packages, Git's own files and the usual build output
are left out. The script's processes get a session of their own, so the
application the package manager started is stopped with it.

An application that ends by itself still ends the container, and
stopping the container stops the application at once. A dev script,
WORKSPACE_NODE_COMMAND and WORKSPACE_NODE_WATCH=0 run without the watcher.
@csandanov
csandanov merged commit 164bf85 into master Oct 8, 2026
1 of 7 checks passed
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