v8/v8.dev

Feature to unblock the Event-Loop automatically after certain period of time.

NayanKaran opened this issue · 0 comments

Currently:

while(1) {
}

in any function would block the event loop.

There should be a function like:

setExecutionTimeout(1000)

which would call:

await setImmediatePromise()

after 1000ms if the function fails to complete it's execution in 1000ms.

which could be defined as:

function setImmediatePromise() {
    return new Promise((resolve) => {
        setImmediate(() => resolve());
    });
}

Other thing could be done is, making

setTimeout(function(){ alert("Hello"); }, 3000);

independent of event loop, so that mission critical functions can run irrespective of other blocking code.