diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-05 09:50:18 -0500 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-08 09:01:54 -0500 |
commit | 568b6a5c9e9893fbb6ab811cfa76841fb3c80a0a (patch) | |
tree | 166114d93b0c6bd7134f9c2b02be7056dff5c408 /test/parallel/test-timers-timeout-to-interval.js | |
parent | 1b05d7bc86d30d47d021cc37476fb0131490a74b (diff) | |
download | android-node-v8-568b6a5c9e9893fbb6ab811cfa76841fb3c80a0a.tar.gz android-node-v8-568b6a5c9e9893fbb6ab811cfa76841fb3c80a0a.tar.bz2 android-node-v8-568b6a5c9e9893fbb6ab811cfa76841fb3c80a0a.zip |
timers: be more defensive with intervals
It's possible for user-code to flip an existing timeout to
be an interval during its execution, in which case the
current code would crash due to start being undefined. Fix
this by providing a default start value within rearm.
PR-URL: https://github.com/nodejs/node/pull/18579
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-timers-timeout-to-interval.js')
-rw-r--r-- | test/parallel/test-timers-timeout-to-interval.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/parallel/test-timers-timeout-to-interval.js b/test/parallel/test-timers-timeout-to-interval.js new file mode 100644 index 0000000000..6952f2231a --- /dev/null +++ b/test/parallel/test-timers-timeout-to-interval.js @@ -0,0 +1,12 @@ +'use strict'; +const common = require('../common'); + +// This isn't officially supported but nonetheless is something that is +// currently possible and as such it shouldn't cause the process to crash + +const t = setTimeout(common.mustCall(() => { + if (t._repeat) { + clearInterval(t); + } + t._repeat = true; +}, 2), 1); |