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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃彈 Debounce all watch operations in the AMP dev toolchain #27738

Merged
merged 3 commits into from Apr 14, 2020
Merged

馃彈 Debounce all watch operations in the AMP dev toolchain #27738

merged 3 commits into from Apr 14, 2020

Conversation

rsimha
Copy link
Contributor

@rsimha rsimha commented Apr 14, 2020

Background:

Several tasks in AMP's gulp toolchain provide watch functionality to enable rebuild-on-edit behavior. However, if a file is saved more than once in a short interval (e.g. hitting Ctrl+S twice in succession), the watcher function is kicked off more than once, which can lead to races in file writes.

PR highlights:

  • Uses debounce for instances of watchify and gulp-watch that use a simple watcher function
  • Uses gulp-debounce for the one instance of gulp-watch that operates on the gulp stream
  • Drive-by minor cleanup of helpers.js, dist.js and lint.js

Tasks fixed by this PR:

# Implicit watch
gulp
gulp serve

# Explicit watch
gulp build --watch
gulp dist --watch
gulp lint --watch

Fixes #27722

@rsimha rsimha self-assigned this Apr 14, 2020
Copy link

@dreamofabear dreamofabear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Looks reasonable to me though not familiar with this code.

Not sure why the double-save consistently happens for me. Might be related to "on save" actions from ESLint/Prettier plugins in VSCode.

@rsimha rsimha requested a review from estherkim April 14, 2020 18:27
@rsimha
Copy link
Contributor Author

rsimha commented Apr 14, 2020

Thanks for the fix! Looks reasonable to me though not familiar with this code.

Added @estherkim for overall build-system/ review.

Not sure why the double-save consistently happens for me. Might be related to "on save" actions from ESLint/Prettier plugins in VSCode.

@choumx The editor.codeActionsOnSave setting has been enabled for users of the eslint plugin via amphtml/.vscode/settings.json.

"editor.codeActionsOnSave": {"source.fixAll.eslint": true},

Could it be that in addition to this, you also have editor.formatOnSave enabled in the settings.json for your local workspace?

@rsimha
Copy link
Contributor Author

rsimha commented Apr 14, 2020

Bumping this since it lacks an approving review.

/cc @ampproject/wg-infra

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

Successfully merging this pull request may close these issues.

gulp: "Uncaught SyntaxError" during rebuild
5 participants