nx icon indicating copy to clipboard operation
nx copied to clipboard

feat(core): support long-running tasks as dependencies

Open luxaritas opened this issue 2 years ago • 9 comments

Current Behavior

Running a task where dependencies do not exit causes the task to stall on the dependency

Expected Behavior

If a task is long-running and not the primary task, it will wait until any declared outputs are present, but otherwise it will not block. If any dependencies are noted as long-running, task output will be prefixed with the package name

Open Questions

  • Is there a good way to add automated tests for this?
  • Is the output format appropriate?
  • Is using the current definition of a "long running task" reasonable?
  • Where should this behavior be documented?

Related Issue(s)

Fixes #5570

luxaritas avatar Jun 11 '22 05:06 luxaritas

☁️ Nx Cloud Report

CI is running/has finished running commands for commit ef1351b2387ecaccc3145af3745ae713ab99f307. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 12 targets

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Jun 11 '22 05:06 nx-cloud[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Jun 11, 2022 at 5:27AM (UTC)

vercel[bot] avatar Jun 11 '22 05:06 vercel[bot]

Just realized this may not work properly with run-many. The way I implemented this, it blocks if the task is for the initiating project, but what if there are multiple initiating projects? I suppose it should still work as long as the max parallel processes is high enough to cover all roots - is that sufficient, or should blocking be initiated somewhere else?

luxaritas avatar Jul 05 '22 14:07 luxaritas

@luxaritas Are you saying that the total number of running watchers cannot exceed the --parallel option/default? That makes sense, but to me the ideal would be that there would be no cap on watchers? Except for a an irrationally large max to protect against accidental loops.

For what it's worth, this feature would help my team greatly if it can be merged into the library. I've been following #5570 and this PR for the last few months.

GYatesIII avatar Jul 14 '22 18:07 GYatesIII

No - I'm saying the total number of root tasks would be limited. Let's say you had 3 apps, each with 20 libs. If you run-many across all 3 libs and your max parallel is 3, no problems. But if your max parallel is 2, only 2/3 of those apps (and their dependencies) would be kicked off

luxaritas avatar Jul 14 '22 18:07 luxaritas

That being said, this PR has been sitting for over a month without any feedback from the Nx team - is there anything I can do to get this queued for review? It's not a particularly large patch

luxaritas avatar Jul 14 '22 18:07 luxaritas

Understood. IMO, doesn't seem like a blocker for this PR as it's easily user-configurable to adjust the --parallel option. A nice-to-have would be to detect this issue at the start by analyzing the dep-graph and exit with a helpful error.

That being said, this PR has been sitting for over a month without any feedback from the Nx team - is there anything I can do to get this queued for review? It's not a particularly large patch

^^ this is mainly why I'm commenting. Hopefully to help add some urgency to get this in.

GYatesIII avatar Jul 14 '22 18:07 GYatesIII

Hey, thanks a lot for the PR 🙇 .

The team is looking into it, but we think we might need some more thought around this and make sure it is designed properly. While watching for outputs might work in most situations there might be a more elegant and robust approach.

Sorry for the delay in responding but there has been lots of stuff going on 😅.

juristr avatar Aug 01 '22 07:08 juristr

Thanks for the response! I'm happy to make adjustments, and would certainly be interested in how this could be made more robust and usable.

luxaritas avatar Aug 01 '22 12:08 luxaritas

Hi, let's keep discussing this in the issue while we design this properly. I'm going to close the PR for now until we settle on a design.

We can reference this solution in the issue. :+1: Thank you for working on it!

FrozenPandaz avatar Aug 17 '22 16:08 FrozenPandaz

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

github-actions[bot] avatar Mar 18 '23 01:03 github-actions[bot]