Why does zipping with periodic() hangs?
See original GitHub issueSummary
I want to print a stream of increasing numbers every 1s, but the code below hangs Node.js forever:
// test.js
const { iterate, periodic } = require('most')
iterate(x => x + 1, 0)
.take(10)
.zip(x => x, periodic(1000))
.forEach(x => console.log(x))
while this
iterate(x => x + 1, 0)
.take(10)
.forEach(x => console.log(x))
terminates as expected.
Expected result
Expected output would be:
$ node test.js
0
1 # after 1s
2 # after 2s
...
Actual Result
$ node test.js
0 # <- hangs here and CPU usage goes up
Versions
- most.js: 1.5.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Phone get hanged while unzipping a file in android
If the app freezes it's usually because you do too much computation on the main/UI thread (note that runOnUiThread() does exactly this).
Read more >Windows 11 File Explorer repeatedly hangs when there is a ...
Windows 11 File Explorer repeatedly hangs when there is a zip file in the folder being viewed. It's a new laptop, was ok...
Read more >Hooke's law - xaktly.com
Hooke's law says that the force produced by a spring is proportional to the displacement (linear amount of stretching or compressing) of that...
Read more >Compress hangs when compressing folders w…
Compress hangs when compressing folders with dot underscore (._*) files. ... And then try to compress folder "a" on the desktop. It will...
Read more >How to Fix Google Drive Zipping Files Stuck | 5 Ways + 2 Tips
Here are 5 solutions to Google Drive zipping 1 file stuck. Let's solve the issue now.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @iwinux, thanks for reporting this. The sample code to reproduce was very helpful! It appears to be a regression in
take
introduced in #428 (technically, a regression inslice
, on whichtake
is based). The regression is causing iterate to run forever, and continuously preempt the periodic task.The reason it manifests with
zip
is thatzip
has to buffer the very fast iterate events, while waiting for corresponding periodic events, which never occur due to the preemption mentioned above.The fix is relatively simple, and I should have time tonight to create a branch so you can try it.
If you’re indeed blocked by needing a periodic counter, then this will work and hopefully unblock you until the fix is ready:
I’m guessing your example is a simplified version of a real use case, so this may not help, but figured it was worth a shot. Cheers!
@iwinux
There’s a candidate fix in #467 (fix-466 branch). Could you give it a try and let us know if it works for you?UPDATE: There’s a slightly cleaner fix in #468 (fix-466-2 branch). Please give that one a try and let us know. Thanks!