-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Watch task outputs to avoid cache restorations #1269
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
On the topic of ensuring that we aren't racing with the filesystem event notifications, More investigation is still required here. |
After the first pass review, and looking over the use of the unix domain socket and pid files, I'm going to make some changes to how we implement the checks for the server being alive. I think the best path forward is to synchronize on the pid file. Whoever owns the pid file is allowed to do whatever they want with the socket file. The server will attempt to lock the pid file, and on success delete any existing socket file and create their own. The client will try to find a live process matching the pid file. If the pid file does not exist, try starting a server. If it exists but the server is not responding, try killing it. If the pid file exists but has no matching process, delete it and try starting a server, or report an error to have the user delete the pid file. At no point will the client manipulate the socket file. It is possible for two clients to race trying to delete a pid file and start a new server, so it may be better to just report an error, or allow for this behavior to be controlled via flag ( |
Investigated golang internal lockfile. I think it's overkill for what we need, especially given that we'd have to do some work to use it, but if someone publishes a nice library around it, we could potentially drop it in. |
beb6ecf
to
640d037
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than delaying anything, just going to get comments in when I have them.
cli/internal/server/turbo_grpc.pb.go
Outdated
@@ -0,0 +1,215 @@ | |||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be checking this generated code in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling to come up with a good opinion on this. There is definitely an argument for "don't check in generated code" on the one hand, but on the other hand, it doesn't seem great to have to run a generate step before vscode will be happy. make turbo
is properly wired up so that it will work either way.
My inclination is to bias towards ease-of-contribution, since I don't think we're particularly susceptible to the problems with checked-in generated code (it's stale -- auto run by our build process, people modify it -- we can watch for it in reviews). But I don't feel super strongly about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could at least partially alleviate the issue using VS Code's tasks.json
(which we should do a better job leveraging at some point anyway).
They have a "runOptions": { "runOn": "folderOpen" }"
that would make things happy. The other thing is I'm not sure if it will ever generate platform-specific code?
cli/internal/daemon/daemon.go
Outdated
base := repoRoot.Base() | ||
logFilename := fmt.Sprintf("%v-%v.log", hexHash, base) | ||
|
||
logsDirRaw, err := xdg.DataFile("logs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ~/Library/Application Support/logs
... we should probably create our own directory to namespace things. Turborepo/logs
, but lol who knows what path structure it needs.
Also, this API from XDG has side effects, so we should consider carefully when this gets called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about a policy of only ever using the "constants" (not actually constant) from xdg
? I put a wrapper in path.go
to get the DataHome
field as an AbsolutePath
. We can use our existing code to do any work we need to do off of that. That gives us better control of the side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 100% on board with getting the base path out of xdg
and then moving it into our path handling infrastructure as soon as possible. That will make our output far more predictable.
…sary .gitignore entry for fake Makefile target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a full checkpoint; if it isn't referenced here it's done.
Old comments:
- #1269 (comment) - I'm not intending to push too hard on this, just want to make sure you saw my follow-on comment.
- #1269 (comment) - I want to change this but since it so easy to change later there's zero reason to block landing on it. I think the number one reason to maybe go ahead and change it is that
tmpfs
fortmp
on Linux may not play nicely with it.
New comments:
- pid extraction is the sole fixship.
- questions on backoff at 2ms
- The pid unlock + signal handling thing has a question about behavior difference, but not intending to block on it.
func backoffWithTimeout(timeout time.Duration) *backoff.ExponentialBackOff { | ||
return &backoff.ExponentialBackOff{ | ||
Multiplier: 2, | ||
InitialInterval: 2 * time.Millisecond, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check to see if we could ever catch it in 1ms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my M1 macbook, it looks like either the initial attempt succeeds (in microseconds), or we wait ~15-25ms to start a daemon and connect.
cli/internal/daemon/daemon.go
Outdated
// If we catch a signal, unlock the pid file. This also wires up | ||
// the pidfile for unlock on program exit. | ||
signalWatcher.AddOnClose(func() { | ||
p.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one that's weird to me; did you get a chance to check what the behavior difference is if we drop it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case I don't get to implementing this, leaving some notes here.
I did some experimentation with sending signals at different points in the execution of this function. It's also important to note that we are not listening to SIGKILL
. Since registering a signal handler alters the default behavior of the runtime, we can block indefinitely on getting a Ctrl+C
/ SIGINT
. This means that rather than needing to register watchers for signals from runTurboServer
, we can instead add the signal watcher's Done()
channel to the select
at the bottom.
This definitely simplifies things, as our defer lock.Unlock()
will always run. I also think it can be the only wait runs: no matter which method of triggering occurs (signal, request handler panic, server goroutine panic), the end result is breaking out the select at the bottom of runTurboServer
. With that in mind, I think we don't noeed the pidLock
abstraction. Future work that might apply would be wiring up a context.NotifyContext
and dropping the signals.Watcher
abstraction.
@nathanhammond I think I've addressed everything, but rather than extract Quick summary is that the |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [turbo](https://turborepo.org) ([source](https://togithub.com/vercel/turborepo)) | [`1.3.1` -> `1.3.4`](https://renovatebot.com/diffs/npm/turbo/1.3.1/1.3.4) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>vercel/turborepo</summary> ### [`v1.3.4`](https://togithub.com/vercel/turborepo/releases/tag/v1.3.4) [Compare Source](https://togithub.com/vercel/turborepo/compare/v1.3.3...v1.3.4) #### What's Changed - fix(deps): update dependency [@​react-types/radio](https://togithub.com/react-types/radio) to v3.2.1 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1553](https://togithub.com/vercel/turborepo/pull/1553) - Move fixtures to correct directory. by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1561](https://togithub.com/vercel/turborepo/pull/1561) - fix(cli): don’t exit when no tasks are found by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1564](https://togithub.com/vercel/turborepo/pull/1564) **Full Changelog**: vercel/turborepo@v1.3.3...v1.3.4 ### [`v1.3.3`](https://togithub.com/vercel/turborepo/releases/tag/v1.3.3) [Compare Source](https://togithub.com/vercel/turborepo/compare/v1.3.2...v1.3.3) #### What's Changed - fix(create-turbo): pnpm peer deps error by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1559](https://togithub.com/vercel/turborepo/pull/1559) **Full Changelog**: vercel/turborepo@v1.3.2...v1.3.3 ### [`v1.3.2`](https://togithub.com/vercel/turborepo/releases/tag/v1.3.2) [Compare Source](https://togithub.com/vercel/turborepo/compare/v1.3.1...v1.3.2) #### Core - Update schema generation script invocation. by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1436](https://togithub.com/vercel/turborepo/pull/1436) - fix(cli): cache with correct file perms by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1429](https://togithub.com/vercel/turborepo/pull/1429) - Watch task outputs to avoid cache restorations by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1269](https://togithub.com/vercel/turborepo/pull/1269) - Vendor chrometracing, add Close method by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1443](https://togithub.com/vercel/turborepo/pull/1443) - Fix symlink mode check. by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1447](https://togithub.com/vercel/turborepo/pull/1447) - Fix hashing uncommitted changes by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1448](https://togithub.com/vercel/turborepo/pull/1448) - Cross-compile amd64. by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1452](https://togithub.com/vercel/turborepo/pull/1452) - fix(cli): prefer IsDir() over explicit type check by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1445](https://togithub.com/vercel/turborepo/pull/1445) - Add test to confirm that file copying works as expected. by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1450](https://togithub.com/vercel/turborepo/pull/1450) - fix: remove suggestion of using fetch-depth by [@​harshcut](https://togithub.com/harshcut) in [https://github.com/vercel/turborepo/pull/1438](https://togithub.com/vercel/turborepo/pull/1438) - Chip away at path migration by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1459](https://togithub.com/vercel/turborepo/pull/1459) - Implement allowing both sides of git comparison by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1442](https://togithub.com/vercel/turborepo/pull/1442) - Move some fields out of Config by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1460](https://togithub.com/vercel/turborepo/pull/1460) - chore: remove redundant `.turbo` by [@​shayc](https://togithub.com/shayc) in [https://github.com/vercel/turborepo/pull/1475](https://togithub.com/vercel/turborepo/pull/1475) - Depending on root tasks should work by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1485](https://togithub.com/vercel/turborepo/pull/1485) - Implement filesystem cookies for filewatch ordering by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1410](https://togithub.com/vercel/turborepo/pull/1410) - Label root package in dependency graph by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1491](https://togithub.com/vercel/turborepo/pull/1491) - Implement fsevents by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1419](https://togithub.com/vercel/turborepo/pull/1419) - Bug: Fix logic that wipes out part of the config by [@​StevenMatchett](https://togithub.com/StevenMatchett) in [https://github.com/vercel/turborepo/pull/1527](https://togithub.com/vercel/turborepo/pull/1527) - Add schema.json to create-turbo templates by [@​jaredpalmer](https://togithub.com/jaredpalmer) in [https://github.com/vercel/turborepo/pull/1537](https://togithub.com/vercel/turborepo/pull/1537) - Filter in package by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1538](https://togithub.com/vercel/turborepo/pull/1538) #### Internal - Ensure we fail if no examples are run by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1441](https://togithub.com/vercel/turborepo/pull/1441) - Bump e2e pnpm to 7 by [@​gsoltis](https://togithub.com/gsoltis) in [https://github.com/vercel/turborepo/pull/1444](https://togithub.com/vercel/turborepo/pull/1444) - Add missing dependencies to OSX setup by [@​trevorr](https://togithub.com/trevorr) in [https://github.com/vercel/turborepo/pull/1487](https://togithub.com/vercel/turborepo/pull/1487) - Add golang to OSX setup by [@​neolivz](https://togithub.com/neolivz) in [https://github.com/vercel/turborepo/pull/1492](https://togithub.com/vercel/turborepo/pull/1492) - Configure Renovate by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1499](https://togithub.com/vercel/turborepo/pull/1499) - chore(deps): update dependency [@​types/react](https://togithub.com/types/react) to v17.0.47 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1514](https://togithub.com/vercel/turborepo/pull/1514) - chore(deps): update dependency ts-json-schema-generator to v0.98.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1516](https://togithub.com/vercel/turborepo/pull/1516) - chore(renovate): support go mod tidy by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1515](https://togithub.com/vercel/turborepo/pull/1515) - fix(deps): update dependency [@​heroicons/react](https://togithub.com/heroicons/react) to v1.0.6 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1520](https://togithub.com/vercel/turborepo/pull/1520) - chore(deps): update dependency [@​babel/core](https://togithub.com/babel/core) to v7.18.6 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1523](https://togithub.com/vercel/turborepo/pull/1523) - chore(deps): update dependency tailwindcss to v3.1.6 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1529](https://togithub.com/vercel/turborepo/pull/1529) - chore(deps): update dependency autoprefixer to v10.4.7 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1530](https://togithub.com/vercel/turborepo/pull/1530) - chore(deps): update dependency eslint-config-prettier to v8.5.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1531](https://togithub.com/vercel/turborepo/pull/1531) - chore(deps): update pnpm/action-setup action to v2.2.2 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1546](https://togithub.com/vercel/turborepo/pull/1546) - chore(deps): update dependency postcss to v8.4.14 by [@​renovate](https://togithub.com/renovate) in [https://github.com/vercel/turborepo/pull/1542](https://togithub.com/vercel/turborepo/pull/1542) - Makefile works for turbobot by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/vercel/turborepo/pull/1550](https://togithub.com/vercel/turborepo/pull/1550) #### Examples - feat(examples): add svelte by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1458](https://togithub.com/vercel/turborepo/pull/1458) - Fix `yarn start` not working by [@​elis](https://togithub.com/elis) in [https://github.com/vercel/turborepo/pull/1468](https://togithub.com/vercel/turborepo/pull/1468) - feat(examples): add tailwind by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1464](https://togithub.com/vercel/turborepo/pull/1464) - fix: added vite.config and fixes for svelte-next.358 by [@​oneezy](https://togithub.com/oneezy) in [https://github.com/vercel/turborepo/pull/1496](https://togithub.com/vercel/turborepo/pull/1496) - chore(examples): update tsconfig declaration val by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1483](https://togithub.com/vercel/turborepo/pull/1483) - feat(examples): add react-native-web by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1486](https://togithub.com/vercel/turborepo/pull/1486) - Fix tailwind example by [@​kocisov](https://togithub.com/kocisov) in [https://github.com/vercel/turborepo/pull/1500](https://togithub.com/vercel/turborepo/pull/1500) - feat(examples): add nextjs by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1506](https://togithub.com/vercel/turborepo/pull/1506) #### Documentation - docs(cli): update contributing.md with new deps by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1449](https://togithub.com/vercel/turborepo/pull/1449) - Update caching.mdx by [@​chitchu](https://togithub.com/chitchu) in [https://github.com/vercel/turborepo/pull/1482](https://togithub.com/vercel/turborepo/pull/1482) - fix(docs): update prune compatibility by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1505](https://togithub.com/vercel/turborepo/pull/1505) - Typo: verifcation --> verification by [@​samouri](https://togithub.com/samouri) in [https://github.com/vercel/turborepo/pull/1517](https://togithub.com/vercel/turborepo/pull/1517) - Add `with-prisma` example by [@​NuroDev](https://togithub.com/NuroDev) in [https://github.com/vercel/turborepo/pull/979](https://togithub.com/vercel/turborepo/pull/979) - feat(examples): add cra by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1504](https://togithub.com/vercel/turborepo/pull/1504) - Examples fast follows by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1526](https://togithub.com/vercel/turborepo/pull/1526) - feat(examples): add docker by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1522](https://togithub.com/vercel/turborepo/pull/1522) - chore(examples): clean the kitchen (sink) by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1534](https://togithub.com/vercel/turborepo/pull/1534) - \[example/kitchensink] allow accessing vite on any ip/hostname by [@​zsoldosp](https://togithub.com/zsoldosp) in [https://github.com/vercel/turborepo/pull/1532](https://togithub.com/vercel/turborepo/pull/1532) - chore(docs): improvements by [@​tknickman](https://togithub.com/tknickman) in [https://github.com/vercel/turborepo/pull/1540](https://togithub.com/vercel/turborepo/pull/1540) #### New Contributors - [@​harshcut](https://togithub.com/harshcut) made their first contribution in [https://github.com/vercel/turborepo/pull/1438](https://togithub.com/vercel/turborepo/pull/1438) - [@​shayc](https://togithub.com/shayc) made their first contribution in [https://github.com/vercel/turborepo/pull/1475](https://togithub.com/vercel/turborepo/pull/1475) - [@​elis](https://togithub.com/elis) made their first contribution in [https://github.com/vercel/turborepo/pull/1468](https://togithub.com/vercel/turborepo/pull/1468) - [@​chitchu](https://togithub.com/chitchu) made their first contribution in [https://github.com/vercel/turborepo/pull/1482](https://togithub.com/vercel/turborepo/pull/1482) - [@​trevorr](https://togithub.com/trevorr) made their first contribution in [https://github.com/vercel/turborepo/pull/1487](https://togithub.com/vercel/turborepo/pull/1487) - [@​oneezy](https://togithub.com/oneezy) made their first contribution in [https://github.com/vercel/turborepo/pull/1496](https://togithub.com/vercel/turborepo/pull/1496) - [@​neolivz](https://togithub.com/neolivz) made their first contribution in [https://github.com/vercel/turborepo/pull/1492](https://togithub.com/vercel/turborepo/pull/1492) - [@​kocisov](https://togithub.com/kocisov) made their first contribution in [https://github.com/vercel/turborepo/pull/1500](https://togithub.com/vercel/turborepo/pull/1500) - [@​renovate](https://togithub.com/renovate) made their first contribution in [https://github.com/vercel/turborepo/pull/1499](https://togithub.com/vercel/turborepo/pull/1499) - [@​samouri](https://togithub.com/samouri) made their first contribution in [https://github.com/vercel/turborepo/pull/1517](https://togithub.com/vercel/turborepo/pull/1517) - [@​NuroDev](https://togithub.com/NuroDev) made their first contribution in [https://github.com/vercel/turborepo/pull/979](https://togithub.com/vercel/turborepo/pull/979) - [@​zsoldosp](https://togithub.com/zsoldosp) made their first contribution in [https://github.com/vercel/turborepo/pull/1532](https://togithub.com/vercel/turborepo/pull/1532) - [@​StevenMatchett](https://togithub.com/StevenMatchett) made their first contribution in [https://github.com/vercel/turborepo/pull/1527](https://togithub.com/vercel/turborepo/pull/1527) **Full Changelog**: vercel/turborepo@v1.3.1...v1.3.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/singlestone/sugar). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMjIuMSIsInVwZGF0ZWRJblZlciI6IjMyLjEyMi4xIn0=-->
Start a daemon, notify it of output globs when a task completes, watch those outputs, check if we can skip cache restores on subsequent runs.
Uses
grpc
andprotobuf
for communication.Before shipping:
--no-daemon
flag torun
daemon status
daemon stop
daemon start
daemon restart
protos
inMakefile