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

fix: rework runSequentialHandlers plugin ordering #5751

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

kanej
Copy link
Member

@kanej kanej commented Sep 16, 2024

The plugin reverse ordering of handlers makes sense for the chained
running of hooks but is wrong for the sequential running, where
dependent plugins should run before the dependee.

We make several moves:

  • remove the getHandlers method from the API as it is only used
    internally to the hook manager
  • create equivalents to getHandlers with explicit logic for reversing
    the plugin order for chained running, and keeping the dependency order
    for sequential.

Reviewers Suggestion

This PR should be reviewed a commit at a time to avoid the jitter from the test restructuring.

In prep for extending the `runSequential` tests, break out the
`beforeEach` sections to allow for variation in the tests.
We have a bug where if two plugins A and B, that both use the `hre/created` hook,
where B depends on A, then we are seeing B run first then A run second.

The ordering tests against the chained run have also been expanded.
The plugin reverse ordering of handlers makes sense for the chained
running of hooks but is wrong for the sequential running, where
dependent plugins should run before the dependee.

We make several moves:

- remove the `getHandlers` method from the API as it is only used
  internally to the hook manager
- create equivalents to `getHandlers` with explicit logic for reversing
  the plugin order for chained running, and keeping the dependency order
  for sequential.
Copy link

vercel bot commented Sep 16, 2024

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

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2024 5:17pm

Copy link

changeset-bot bot commented Sep 16, 2024

⚠️ No Changeset found

Latest commit: 3dd37fe

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Sep 16, 2024
@kanej kanej marked this pull request as ready for review September 16, 2024 12:17
@kanej kanej changed the title test: split up before phase for hook manager tests fix: rework runSequentialHandlers plugin ordering Sep 16, 2024
Copy link
Member

@alcuadrado alcuadrado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment re order

We change the ordering of dynamic hooks in run sequential, so that it is
in effect the reverse of running chained.

Plugins are now run first, with dynamic handlers coming second.

Plugins run in resolved dependency order (if B depends on A, A runs
before B).

Dynamic handlers are run in the order they are registered.

The tests and docs have been updated to reflect this change.
@kanej kanej added this pull request to the merge queue Sep 16, 2024
Merged via the queue into v-next with commit 1500c66 Sep 16, 2024
29 checks passed
@kanej kanej deleted the fix/run-sequential-hook-ordering branch September 16, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants