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

Compilation cancelation #1083

Closed
rauchg opened this issue Feb 11, 2017 · 7 comments
Closed

Compilation cancelation #1083

rauchg opened this issue Feb 11, 2017 · 7 comments
Labels
Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). Webpack Related to Webpack with Next.js.
Milestone

Comments

@rauchg
Copy link
Member

rauchg commented Feb 11, 2017

Sometimes you make a change, then want to quickly make another change
Webpack doesn't seem to do cancelation by default? Which means a lot of wasted time!

@rauchg
Copy link
Member Author

rauchg commented Feb 14, 2017

+1. This is really really annoying

@rauchg
Copy link
Member Author

rauchg commented Feb 14, 2017

@msand thanks for pinging that issue.

I just realized not having cancelation is not only a "nice to have", but it's absolutely critical for scenarios like changes that happen in quick succession. For example, git checkout.

@linus-amg
Copy link

linus-amg commented Oct 10, 2017

Maybe during the build something could listen (somehow connected to watching file saves/changes) and throw an error, so the build fails/stops, so before every save of a file the current build listening (if there is one running) would fail before the next one starts. Would building something for that somehow be an OK solution to this issue?

@shuding
Copy link
Member

shuding commented Jun 4, 2018

Just saw webpack/webpack#1702 this issue and @TheLarkInn mentioned that Nuxt.js does great for this.

So I read its code and seems Nuxt.js is using chokidar as the file watcher rather than Webpack, and also it's using _.debounce to avoid rebuild caused by quick file changes (see https://github.com/nuxt/nuxt.js/blob/master/lib/builder/builder.js#L660). But it also increases the delay by a little bit.

Webpack supports this "rebuild delay" and we can add this feature to Next.js really quickly by add watchOptions.aggregateTimeout (see https://webpack.js.org/configuration/watch/#watchoptions-aggregatetimeout) here: https://github.com/zeit/next.js/blob/canary/server/hot-reloader.js#L223.

What do you say? I think this might be very useful.


UPDATE:
Looks like Webpack is using aggregateTimeout=300ms by default.
So we need real "cancelation" still.

@shuding
Copy link
Member

shuding commented Jun 4, 2018

I'd like to try implementing a demo using the idea of Webpack's watching.invalidate() and chokida.

@shuding
Copy link
Member

shuding commented Jun 5, 2018

Hmmm seems really hard to implement it. I digged into the Webpack code and it turns out that, in the watch mode, although there's an undelayed callback for the file watcher, but the file change event will still be blocked by the current compilation. Maybe it's because the ongoing compilation and the file watcher run in the same single thread.

Same issue here: webpack/webpack#5929

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

6 participants