Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!