scramjetorg / scramjet

Public tracker for Scramjet Cloud Platform, a platform that bring data from many environments together.
https://www.scramjet.org
MIT License
253 stars 20 forks source link

DataStream.flatMap causes stream to end early #99

Closed maxharlow closed 3 years ago

maxharlow commented 3 years ago

When I use flatMap the stream seems to end prematurely in some circumstances. For example:

const Scramjet = require('scramjet')

const array = Array.from(new Array(50).keys())
Scramjet.DataStream.from(array)
    .flatMap(x => [x, x])
    .each(console.log)

I'd expect this to print out every number from 0 to 49 twice. Instead it consistently stops at 14. If I change the flatMap line to be x => [x] it runs all the way through as expected. Changing it to x => [x, x, x] makes it run through to 24.

I'm using Scramjet v4.35.10 and Node v15.5.1.

maxharlow commented 3 years ago

Downgrading to Scramjet v4.23.2 seems to fix the problem

MichalCz commented 3 years ago

Thanks for the info, will check today and report back

MichalCz commented 3 years ago

BTW, can you check if you get to see the end event?

maxharlow commented 3 years ago

Brilliant, thanks. How do I check for the end event?

MichalCz commented 3 years ago

on('end', / some callback here /)

On Mon, 18 Jan 2021, 11:52 Max Harlow, notifications@github.com wrote:

Brilliant, thanks. How do I check for the end event?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/signicode/scramjet/issues/99#issuecomment-762165631, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ3RBFE5GX4H3FB2SNJCX3S2QHGNANCNFSM4WFJX2CQ .

maxharlow commented 3 years ago

Just checked, no end event

MichalCz commented 3 years ago

Ok. Then it should be an easy fix.

M.

On Mon, 18 Jan 2021, 12:52 Max Harlow, notifications@github.com wrote:

Just checked, no end event

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/signicode/scramjet/issues/99#issuecomment-762200190, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ3RBBOP2JQU7DM4HCC7C3S2QOGHANCNFSM4WFJX2CQ .

MichalCz commented 3 years ago

Max, I've found a fix, but I do need to investigate a bit and clean up the code after all this.

I can commit to Monday, I hope this works for you.

maxharlow commented 3 years ago

That's great! No rush, I can use the older version for now

MichalCz commented 3 years ago

@maxharlow this is fixed in scramjet@4.35.11