Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
Programmatically handling unresponsive scripts / endless loops

I am running untrusted scripts in a WebAssembly sandbox (using a non-JS interpreter written in WASM). It is possible for these untrusted scripts to run an endless loop that would make the main application unresponsive. Is it possible to set a "timer interrupt" on a function that is expected to terminate within N milliseconds?

Pseudocode example:

const timeoutMS = 1000;
const untrustedFn = () => {};

// Theoretical function. I don't know if modern JS environments
// support this.
// This will throw an exception if `untrustedFn` does not finish in 1000 ms.
finishExecutionWithinMs(timeoutMS, untrustedFn);
  • setTimeout would not be possible here since the endless loop would block the event loop from servicing the callback.
  • Running the script in a worker is possible, but I am looking for a simpler alternative.
  • Many browsers support automatically terminating unresponsive scripts, but I need a higher level of granularity (need to be able to configure the timeout interval and handle failure in a catch)

Do modern browsers support functionality like this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda