Skip to content

Instantly share code, notes, and snippets.

@evanlucas
Created February 1, 2018 16:31
Show Gist options
  • Save evanlucas/e41c181fb0175ff588acd12a060b3c1e to your computer and use it in GitHub Desktop.
Save evanlucas/e41c181fb0175ff588acd12a060b3c1e to your computer and use it in GitHub Desktop.
async-listener fails with promisified sleep
'use strict'
const {promisify} = require('util')
const args = process.argv.splice(2)
for (const arg of args) {
if (arg === 'async-listener') require('async-listener')
}
const sleep = promisify(setTimeout)
console.log('sleep')
;(async () => {
await sleep(500)
console.log('500ms')
await sleep(1500)
console.log('1500ms')
})().catch(console.error)
// `node test.js` works
// `node test.js async-listener` fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment