Created
February 1, 2018 16:31
-
-
Save evanlucas/e41c181fb0175ff588acd12a060b3c1e to your computer and use it in GitHub Desktop.
async-listener fails with promisified sleep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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