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

AsyncParallelBailHook keeps executing even after one of the tapped functions has produced a defined value #130

Open
nshimiye opened this issue Aug 1, 2020 · 3 comments

Comments

@nshimiye
Copy link

nshimiye commented Aug 1, 2020

Consider this example

const { AsyncParallelBailHook } = require("tapable");

const hook = new AsyncParallelBailHook();
hook.tapPromise('A', () => new Promise(res => setTimeout(() => res(undefined), 100)));
hook.tapPromise('B', () => new Promise(res => setTimeout(() => res('B'), 5000))); // <= last to resolve
hook.tapPromise('C', () => new Promise(res => setTimeout(() => res('C'), 500)));

hook.promise().then(console.log);

Expected (hook is expected to use value from the third tap)

C

Actual (hook uses value from second tap instead)

B
@nshimiye
Copy link
Author

nshimiye commented Aug 1, 2020

I have proactively looked and proposed a change that would fix the above issue, if you guys think it is an issue!

@sokra
Copy link
Member

sokra commented Aug 1, 2020

This is working as expected. It's not a race, it returns the first defined value by plugin order. This way the behavior is always deterministic and independent of timing.

@nshimiye
Copy link
Author

nshimiye commented Aug 2, 2020

I see, thx for clarification @sokra !
Would it be possible to point me to a doc/reference that explains more about the plugin order
I think that will help me figure out how to use tapable for my use-case and maybe add a test case to help others understand the expected behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants