Disable slack overflow in the simulator?

Hello all Wave tone1,

I am working on a mock, acting as a `Toybox.BluetoothLowEnergy` replacement.

It thus have to print the command sent, as well as triggering the correct delegate with the correct value...

But I always get a 'Stack Overflow Error', has the number of functions on the stack can be quite larger than the 8 (from memory) the physical stack can handle.

My question is then the following:

Is there a way to run the simulator so that the 'Stack Overflow Error' is ignored?

Thank you!

++GG

ps: I am not using any testing feature. Should I?

  • I still can't see why CIQ is even involved, and might not even be an issue in something like python.

    OP is trying to mock out certain parts of their app for the purposes of testing.

    e.g.

    [https://circleci.com/blog/how-to-test-software-part-i-mocking-stubbing-and-contract-testing/]

  • Hey Guys! Time's up! Stop arguing, please. It wasn't intended to result in a "who's the biggest" contest.Stuck out tongue closed eyes Sorry about that.

    You both gave me valuable informations and food for thoughts, and I am indeed deeply thankful for that.

    However, I think @ did well understand the problem I am facing. I will thus give his solution a try.

    50ms is the min timer

    Thanks for the warning! But I can definitely go with that, even if testing the whole app ends up eating the whole afternoon Astonished

    Thank you both for your help, and I'll try to get back to you as soon as I can...

    Cheers!

    ++GG

  • The “Stack Overflow Error” you’re encountering happens because the simulator’s call stack exceeds its limits—likely due to recursive calls or event triggers that keep calling themselves when you try to mock Toybox.BluetoothLowEnergy. Unfortunately, most simulators and runtime environments do not allow ignoring stack overflow errors, because they indicate a real risk of unstable behavior.

    Instead, the recommended approach is to restructure your mock to avoid deep recursion:

    1. Decouple the delegate triggers from the command printing so that calling one doesn’t immediately call the other in a loop.

    2. Use queues or buffers to handle commands and events instead of calling delegates synchronously. This way, you can process events step by step, avoiding stacking too many function calls.

    3. Limit recursion depth manually if your framework allows it, or simulate asynchronous behavior to spread calls over time.

    By redesigning the mock to handle commands and delegate calls iteratively rather than recursively, you can prevent stack overflow while keeping the simulator functional.

    If you’re testing many scenarios automatically, a test generator can help create structured test cases that exercise your mock without hitting stack limits, saving time and reducing manual trial-and-error.