abbr / deasync

Turns async function into sync via JavaScript wrapper of Node event loop
MIT License
971 stars 73 forks source link

Doesn't work with `puppeteer` #150

Closed szmarczak closed 3 years ago

szmarczak commented 3 years ago

The following code hangs indefinitely:

const deasync = require('deasync');
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');

  // This works
  console.log(await page.evaluate('document.title'));

  // This does not
  const title = deasync(page.evaluate.bind(page))('document.title');
  console.log(title);

  await browser.close();
})();
szmarczak commented 3 years ago

This is basically #40