mostjs / core

Most.js core event stream
http://mostcore.rtfd.io
MIT License
402 stars 36 forks source link

Stack overflow error #660

Open stevexbritton opened 2 years ago

stevexbritton commented 2 years ago

Hi,

I really like this implementation of frp, but have come across a problem with the following code:

let count = 0
await runEffects(
    tap(
        (it: number | void) => {
            console.log(count++)
            // console.log(`${stackDepth()}`)
            // console.log(new Error().stack)
            // console.trace()
        },
        // periodic(10)
        animationFrames(window)
    ),
    newDefaultScheduler()
)

This causes an "Uncaught RangeError: Maximum call stack size exceeded" after about 11000 cycles in Chrome on a Mac. A similar error occurs in Firefox and Safari just gets bigger. If I switch from the animationFrames stream to the periodic stream the error does not occur. However, looking at the console.trace produced by Chrome I'm not sure why not.

I know animationFrames is experimental, but I would be grateful if you would have a look at this issue for me. I'm concerned the problem is within the runEffects function and not the animationFrames function.

Thanks in advance, Steve

Frikki commented 2 years ago

@TylorS @briancavalier Do you have any idea of why this is happening?

stevexbritton commented 2 years ago

Hi, Thanks for responding. Yes, I know what the problem is. On line 22 of file "x-animation-frame/src/index.js" the code goes recursive with its call to "animationFrames(afp)". Steve

Frikki commented 2 years ago

So we are talking about this line https://github.com/mostjs/x-animation-frame/blob/9e03e9de9640022fd67fbe861b6c6937ced0d040/src/index.js#L22

I’ll see if I get some time to test it. Thanks for opening the issue.

stevexbritton commented 2 years ago

Yes, you can see it calls itself. Thanks, Steve