How to cancel timeout inside of Javascript Promise?
Edit 2021 all platforms have converged on AbortController as the cancellation primitive and there is some built in support for this. In Node.js // import { setTimeout } from ‘timers/promises’ // in ESM const { setTimeout } = require(‘timers/promises’); const ac = new AbortController(); // cancellable timeout (async () => { await setTimeout(1000, null, { … Read more