Skip to content

[rush] beforeInstall hook invokes on a different set of conditions than afterInstall hook #5168

Open
@kevin-y-ang

Description

@kevin-y-ang

Summary

I was hoping that that if the beforeInstall hook runs, then there would be some guarantee that the afterInstall hook will run and vice versa. That turns out not to be the case in the following scenarios:

  1. If installation is already up-to-date, then the beforeInstall hook will not invoke, but the afterInstall hook will.
  2. If the installation fails, then the afterInstall hook will not invoke. This is unexpected because I was hoping to do some cleanup actions in the afterInstall hook.

It would be trivial for me to make this change in a PR but it would be a bit of a breaking change. Even so, I think it still might be worth considering because I think it's a common enough use case to use the 2 hooks in tandem, with the afterInstall hook being a cleanup function for the beforeInstall hook.

Source code file in question

Details

My use case is being able to measure granular subspace-by-subspace install duration metrics. This data would be much more useful for my team than the all-in-one durationInSeconds field provided by the flushTelemetry hook, which adds up the total duration of installation times for however many subspaces targeted by the rush install command.

Standard questions

Question Answer
@microsoft/rush globally installed version? 5.149.0
rushVersion from rush.json? 5.149.0
useWorkspaces from rush.json? No
Operating system? Unix
Would you consider contributing a PR? Yes
Node.js version (node -v)? 18.20.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: mediumNeeds a somewhat experienced developerhelp wantedIf you're looking to contribute, this issue is a good place to start!

    Type

    No type

    Projects

    Status

    Low priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions