Skip to content

JavaScript setTimeout infinite loop without recursion #324

Closed
@odykyi

Description

@odykyi

https://stackoverflow.com/questions/51953379/javascript-settimeout-infinite-loop-without-recursion/52100787

I cannot use Obfuscator.io(https://obfuscator.io/)
to uglify my JS script because it contains a setTimeout within a function that calls itself.
MCVE:

function repeater() {
    // DO SOME STUFF...
    setTimeout(repeater, 100);
}
repeater();

Custom obfuscation settings required to reproduce:

  • Identifier Names Generator: Mangled
  • Reserved Names: $ - jQuery

Obfuscator.io's error message:

Error: @PostConstruct error in class t: @PostConstruct error in class t: Maximum call stack size exceeded

I've read a few other Stack Overflow questions about this. I understand that calling setTimeout(func) inside func is not actually recursion.

But still, Obfuscator.io's algorithm can't handle a self-invoking setTimeout delay.

How do I make a repeatedly-executing function using setTimeout without calling it in the function itself? I don't want to use setInterval because I want the delay to begin each time after the function's code has run. setInterval ignores that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions