title: async / await with socket.io
body: <p>This code send the first emit to client and client get the messageStart : 'Job is starting...' This is OK.
  After that the code launch puppeteer and make the screen shot example.png. This is OK too.
  But the second emit is not fired and not send to client.
  In the console.log of the server I get :</p>
  
  <ul>
  <li>job is starting </li>
  <li>CAPTURE FINISHED</li>
  <li>job is finished</li>
  </ul>
  
  <p>This is OK too.</p>
  
  <p>What happened? Why is the second emit not fired?</p>
  
  <pre><code>const express = require('express');
  const puppeteer = require('puppeteer')
  const app = express();
  const server = app.listen(3000);
  
  app.set('view engine', 'ejs');
  var io = require('socket.io').listen(server);
  
  app.get('/', function (req, res, next) {
    res.render('index');
  });
  
  app.get('/scan', function (req, res, next) {
    console.log('job is starting');
  
    io.sockets.on('connection', function (socket) {
      socket.emit('messageStart', 'Job is starting...');
    });
  
    (async () =&gt; {
      const browser = await puppeteer.launch({headless:false});
      const page = await browser.newPage();
      await page.goto('https://example.com');
      await page.screenshot({ path: 'example.png' });
      await browser.close();
      console.log('CAPTURE FINISHED');
    })().then(()=&gt;{
        console.log('job is finished');
  
        io.sockets.on('connection', function (socket) {
            socket.emit('messageEnd', 'Job is done!');
          });
      });
    res.render('scan');
  });
  </code></pre>