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

Hooks are duplicated on got.extend(...) #1163

Closed
szmarczak opened this issue Apr 20, 2020 · 1 comment
Closed

Hooks are duplicated on got.extend(...) #1163

szmarczak opened this issue Apr 20, 2020 · 1 comment
Labels
bug Something does not work as it should regression Something does not work anymore

Comments

@szmarczak
Copy link
Collaborator

This is because defaults.hooks is set on options.hooks twice:

options = {...defaults as NormalizedOptions, ...options};

got/source/core/index.ts

Lines 784 to 794 in 1f6ac45

for (const event of knownHookEvents) {
const defaultHooks = defaults.hooks[event];
if (defaultHooks.length !== 0) {
// See https://github.com/microsoft/TypeScript/issues/31445#issuecomment-576929044
(options.hooks as any)[event] = [
...defaults.hooks[event],
...options.hooks[event]!
];
}
}

@szmarczak szmarczak added bug Something does not work as it should regression Something does not work anymore labels Apr 20, 2020
@szmarczak
Copy link
Collaborator Author

Fixed in d914a7e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should regression Something does not work anymore
Projects
None yet
Development

No branches or pull requests

1 participant