Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process is not restarted when dependency has been changed #1

Open
orjan opened this issue May 8, 2024 · 0 comments
Open

Process is not restarted when dependency has been changed #1

orjan opened this issue May 8, 2024 · 0 comments

Comments

@orjan
Copy link
Owner

orjan commented May 8, 2024

Problem

server:serve is not restarted even if the dependency has been changed

This is a simplistic example of a build process that in a real world would be running tsc instead of just copying a file.
The serve command it pretty realistic for an express application.

Different kind of persistent tasks

I don't think this is covered in the configuration but there a difference between node and node --watch. The first one needs to be restarted when a dependency has been change and that later is responsible for taking care of updates on its own. In this case however I'm more interested in the first once since turbo is the only one with knowledge of the dependency chain and the one that knows when it's needed to restart or not.

How to run

npx turbo@1.13.4-canary.2 watch serve
• Packages in scope: server
• Running serve in 1 packages
• Remote caching disabled
server:serve: cache bypass, force executing 82a3aea137e3fb4d
server:build: cache hit (outputs already on disk), replaying logs 7fccac5d6afa1a65
server:build:
server:build: > server@1.0.0 build
server:build: > mkdir -p dist && cp src/index.js dist/.
server:build:

 Tasks:    1 successful, 1 total
Cached:    1 cached, 1 total
  Time:    48ms >>> FULL TURBO

server:serve:
server:serve: > server@1.0.0 serve
server:serve: > node dist/index.js
server:serve:
server:serve: Server is running v1.0.0 1
server:serve: Server is running v1.0.0 2

Trigger a change in the build dependency

E.g. change applicationVersion in src/index.js to something else

server:build: cache miss, executing 75d7ab0d4cd54cf3
server:build:
server:build: > server@1.0.0 build
server:build: > mkdir -p dist && cp src/index.js dist/.
server:build:

 Tasks:    1 successful, 1 total
Cached:    0 cached, 1 total
  Time:    305ms

server:serve: Server is running v1.0.0 6
server:serve: Server is running v1.0.0 7

As you can see the v1.0.0 is still being logged even if the dependency has been rebuilt.

References

I tried to remove the dependency on build from the serve task to simplify the dependency chain but then it won't start at all running the watch command.

It looks like there's some code in place to actually abort the persisted task when changed, but I'm not familiar with the implementation?
https://github.com/vercel/turbo/blob/7a9d83956cc6c0145ed5abdedb2080dec753d09b/crates/turborepo-lib/src/run/watch.rs#L291

There are some issues open that's related to the dependency chain but I'm not sure if it could be related?
vercel/turbo#8051

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

No branches or pull requests

1 participant