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

Prevent callback from firing multiple times #12

Merged
merged 1 commit into from Mar 13, 2018
Merged

Prevent callback from firing multiple times #12

merged 1 commit into from Mar 13, 2018

Conversation

Nayni
Copy link
Contributor

@Nayni Nayni commented Mar 13, 2018

Took me a little to figure this out, but the solution was pretty simple actually.

When tsconfig-paths returned with an error the original code would invoke the callback but it would then fall-through to still try doResolve which would in turn invoke the callback again.

The different between Webpack 3 and Webpack 4 is that in version 3 they used async to wrap their callbacks but with version 4 this was replaced by neo-async which prevents you from calling the same callback multiple times.

I refactored it for both versions so that the callback is invoked and returned early. Knowing that tsconfig-paths already errored there is no reason to even try and resolve.

I also slightly changed both inner callbacks to be more consistent as I spotted a potential issue (I wrote some comments to explain).

Hopefully this fixes #11 (Although it will probably just show an error from tsconfig-paths now, but that should hopefully be solvable ;-))

@Nayni
Copy link
Contributor Author

Nayni commented Mar 13, 2018

Please also check out: dividab/tsconfig-paths#29 it's probably related.

@jonaskello
Copy link
Member

I merged and released dividab/tsconfig-paths#29 in tsconfig-paths 3.1.2. I will update the plugin to use that version after merging this too.

@jonaskello jonaskello merged commit 5b348e8 into dividab:master Mar 13, 2018
@jonaskello
Copy link
Member

This is now released in 3.0.1.

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

Successfully merging this pull request may close these issues.

Callback was already called
2 participants