Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

fix(watch): Ensure that watch tasks are throttled to run one at a time per watcher. #44

Merged
merged 1 commit into from
Sep 30, 2016

Conversation

jthoms1
Copy link
Contributor

@jthoms1 jthoms1 commented Sep 29, 2016

This PR should prevent the memory overruns that we have seen from rollup. The code ensures that we are running only watch task at a time by using the returned promises. It also uses a single entry queue so that we only run one additional watch task on previous task completion.

@Manduro
Copy link
Contributor

Manduro commented Sep 29, 2016

@jthoms1 Thank you for this fix! Is it possible that saving a lot of files right after each other creates a huge queue for compiling?

Another solution would be to cancel the current task and start a new one right away, instead of waiting for the current task to finish. That should be faster, right?

@jthoms1
Copy link
Contributor Author

jthoms1 commented Sep 29, 2016

Yes this creates a big queue it seems. This fix should resolve that. I would prefer we let the current finish because I don't want to make any assumptions about the current state at any point in time. Just being safe about it.

@Aristona
Copy link

Aristona commented Oct 2, 2016

Thanks alot!

@Manduro
Copy link
Contributor

Manduro commented Oct 3, 2016

@jthoms1 Just had another one with the latest ionic-app-scripts that included this fix:

[11:59:14]  typescript compilation started ...
[11:59:15]  templateUpdate started ...
[11:59:15]  bundle dev update started ...
[11:59:24]  typescript compilation finished in 10.03 s
[11:59:24]  bundle dev update started ...
[11:59:24]  RangeError: Maximum call stack size exceeded
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:153:20)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
    at deepClone (/Users/etc/etc/etc/node_modules/rollup/dist/rollup.js:165:18)
[11:59:24]  sass started ...
[11:59:24]  sass finished in 39 ms
JS changed:   www/build/main.js.map
JS changed:   www/build/main.js
[11:59:35]  bundle dev update finished in 20.73 s
[11:59:35]  templateUpdate finished in 20.74 s

@maxkunitsa
Copy link

maxkunitsa commented Oct 3, 2016

@jthoms1 also got 'Maximum call stack size exceeded' even with version 0.0.27

@ecureuill
Copy link

ecureuill commented Oct 3, 2016

I think it will be necessary to cancel some tasks, maybe conditionally to queue length.
I used to save every line modification and I think this is causing watch to break

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'watch' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle ionic-hello-world@~prewatch: ionic-hello-world@
6 silly lifecycle ionic-hello-world@~prewatch: no script for prewatch, continuing
7 info lifecycle ionic-hello-world@~watch: ionic-hello-world@
8 verbose lifecycle ionic-hello-world@~watch: unsafe-perm in lifecycle true
9 verbose lifecycle ionic-hello-world@~watch: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/sciuro/Projects/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/android-sdk/tools:/opt/android-sdk/platforms-tools
10 verbose lifecycle ionic-hello-world@~watch: CWD: /home/sciuro/Projects
11 silly lifecycle ionic-hello-world@~watch: Args: [ '-c', 'ionic-app-scripts watch' ]
12 silly lifecycle ionic-hello-world@~watch: Returned: code: 134  signal: null
13 info lifecycle ionic-hello-world@~watch: Failed to exec watch script
14 verbose stack Error: ionic-hello-world@ watch: `ionic-app-scripts watch`
14 verbose stack Exit status 134
14 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at EventEmitter.emit (events.js:172:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:87:13)
14 verbose stack     at ChildProcess.emit (events.js:172:7)
14 verbose stack     at maybeClose (internal/child_process.js:829:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid ionic-hello-world@
16 verbose cwd /home/sciuro/Projects
17 error Linux 3.16.0-4-amd64
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch"
19 error node v4.5.0
20 error npm  v3.10.6
21 error code ELIFECYCLE
22 error ionic-hello-world@ watch: `ionic-app-scripts watch`
22 error Exit status 134
23 error Failed at the ionic-hello-world@ watch script 'ionic-app-scripts watch'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ionic-hello-world package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ionic-app-scripts watch
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ionic-hello-world
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ionic-hello-world
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

At least, compared to 0.0.23 version, my memory consumption is better.
I started a new project with 0.0.23 and it was impossible to work on it because of watch.

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

Successfully merging this pull request may close these issues.

6 participants