core icon indicating copy to clipboard operation
core copied to clipboard

Stack overflow error

Open stevexbritton opened this issue 4 years ago • 4 comments

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

stevexbritton avatar Oct 17 '21 14:10 stevexbritton

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

Frikki avatar Nov 19 '21 12:11 Frikki

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

stevexbritton avatar Nov 19 '21 22:11 stevexbritton

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.

Frikki avatar Nov 25 '21 12:11 Frikki

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

stevexbritton avatar Nov 25 '21 17:11 stevexbritton