fix: Wrap hooks now correctly receive options passed by outer wrappers#125
Open
fix: Wrap hooks now correctly receive options passed by outer wrappers#125
Conversation
Owner
yeah I think this needs to be fixed as well, great catch 👍🏼 Can you update your PR? |
auto-merge was automatically disabled
February 18, 2026 20:15
Head branch was pushed to by a user without write access
Author
|
@gr2m Done, and also added another test for that. |
auto-merge was automatically disabled
February 19, 2026 18:19
Head branch was pushed to by a user without write access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I discovered this while working on octokit/plugin-retry.js#661, where there appeared to be no difference between (simplified):
and
I eventually realised that the argument to (in this case)
reqdidn't matter at all and traced the issue down to this library, specifically https://github.com/gr2m/before-after-hook/blob/main/lib/register.js#L23-L25Since the docs, tests, and examples, all show the
optionsbeing passed to the wrapped function, I assume that this is not intentional. This PR fixes the problem so that only the outer-most wrapper gets the initialoptionsobject and the others get the arguments they are called with. I also added a test for this.There is potentially the same issue in https://github.com/gr2m/before-after-hook/blob/main/lib/register.js#L13-L15 but I wasn't sure if maybe it was the intended behaviour there. If not, then the following would fix it: