// Returns T if promise settles before timeout, otherwise returns void, finishing execution in the background. export async function promiseEarlyReturn(promise, after) { const timer = new Promise((res)=>setTimeout(()=>res(undefined), after)); return Promise.race([ promise, timer ]); }