title: mysql2 connection.connect() hangs in typescript jest test on macOS
body: <p>I am trying to create a mysql2 connection to a local mysql-Database in a jest-Test on macOS using typescript. And the call to connect() hangs.</p>
  
  <p>Environment:</p>
  
  <ul>
  <li>MacOS: High Sierra (10.13.6)</li>
  <li>MySQL: 8.0.18</li>
  <li>Typescript: 3.7.2</li>
  <li>mysql2: 2.0.1</li>
  <li>nodejs: v10.16.3</li>
  </ul>
  
  <p>I am using the promise-Wrapper. The code looks like this:</p>
  
  <pre><code>import { createConnection, ConnectionOptions, Connection } from 'mysql2/promise'
  
  ...
  
  async openConnection(options: ConnectionOptions): Promise&lt;Connection&gt; {
      console.log('About to create mysql connection using options ', options);
  
      const connection = await createConnection(options);        
      console.log('Connection created =&gt; about to call connect()');
  
      await connection.connect();
      console.log('Connection created =&gt; connect() returned');  // this line is never reached!
      ....
      return connection;
  }
  </code></pre>
  
  <p>I already added the debug-Option and this is the output:</p>
  
  <pre><code>Dieters-MBP-6:db-typescript rehdie$ node_modules/.bin/jest src/tests/mysql/mysql-connection.spec.ts --testNamePattern="Should open connection" 
    console.log src/lib/mysql/driver/mysql-driver.ts:21
      About to create mysql connection using options  { user: 'mysql-test',
        password: '1q2w3e4r',
        host: 'localhost',
        port: 3306,
        database: 'mysql_test_db',
        charset: 'latin1_swedish_ci',
        connectTimeout: 5000,
        debug: true }
  
    console.log node_modules/mysql2/lib/connection.js:425
      Add command: ClientHandshake
  
    console.log node_modules/mysql2/lib/connection.js:381
       raw: 0a382e302e31380018000000277919626469296e00ffffff0200ffc715000000000000000000006d6335316a3c3d454220053a0063616368696e675f736861325f70617373776f726400
  
    console.error console.js:274
      Trace: 
          at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
          at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
          at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
          at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
          at Socket.emit (events.js:198:13)
          at addChunk (_stream_readable.js:288:12)
          at readableAddChunk (_stream_readable.js:269:11)
          at Socket.Readable.push (_stream_readable.js:224:10)
          at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  
    console.log node_modules/mysql2/lib/connection.js:395
      0 undefined ==&gt; ClientHandshake#unknown name(0,,78)
  
    console.log node_modules/mysql2/lib/commands/client_handshake.js:96
      Server hello packet: capability flags:3355443199=(long password, found rows, long flag, connect with db, no schema, compress, odbc, local files, ignore space, protocol 41, interactive, ssl, ignore sigpipe, transactions, reserved, secure connection, multi statements, multi results, ps multi results, plugin auth, connect attrs, plugin auth lenenc client data, can handle expired passwords, session track, deprecate eof, ssl verify server cert, remember options)
  
    console.log node_modules/mysql2/lib/commands/client_handshake.js:41
      Sending handshake packet: flags:11203535=(long password, found rows, long flag, connect with db, odbc, local files, ignore space, protocol 41, ignore sigpipe, transactions, reserved, secure connection, multi results, plugin auth, plugin auth lenenc client data, session track)
  
    console.log node_modules/mysql2/lib/connection.js:253
      0 24 &lt;== ClientHandshake#unknown name(1,,104)
  
    console.log node_modules/mysql2/lib/connection.js:257
      0 24 &lt;== 64000001cff3aa00000000000800000000000000000000000000000000000000000000006d7973716c2d746573740014a13dd11599725225bcae39464cc3700a5fa085fc6d7973716c5f746573745f6462006d7973716c5f6e61746976655f70617373776f726400
  
    console.log node_modules/mysql2/lib/connection.js:381
       raw: fe63616368696e675f736861325f70617373776f726400277919626469296e6d6335316a3c3d454220053a00
  
    console.error console.js:274
      Trace: 
          at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
          at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
          at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
          at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
          at Socket.emit (events.js:198:13)
          at addChunk (_stream_readable.js:288:12)
          at readableAddChunk (_stream_readable.js:269:11)
          at Socket.Readable.push (_stream_readable.js:224:10)
          at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  
    console.log node_modules/mysql2/lib/connection.js:395
      0 24 ==&gt; ClientHandshake#unknown name(2,,48)
  
    console.log node_modules/mysql2/lib/connection.js:253
      0 24 &lt;== ClientHandshake#unknown name(3,,36)
  
    console.log node_modules/mysql2/lib/connection.js:257
      0 24 &lt;== 20000003374930d53dd94bc2dbe6b54e4b83cd628658a1984656eb6ee4f31d7df596ce36
  
    console.log node_modules/mysql2/lib/connection.js:381
       raw: 0103
  
    console.error console.js:274
      Trace: 
          at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
          at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
          at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
          at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
          at Socket.emit (events.js:198:13)
          at addChunk (_stream_readable.js:288:12)
          at readableAddChunk (_stream_readable.js:269:11)
          at Socket.Readable.push (_stream_readable.js:224:10)
          at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  
    console.log node_modules/mysql2/lib/connection.js:395
      0 24 ==&gt; ClientHandshake#unknown name(4,,6)
  
    console.log node_modules/mysql2/lib/connection.js:381
       raw: 000000024000000010010e0d6d7973716c5f746573745f6462
  
    console.error console.js:274
      Trace: 
          at Connection.handlePacket (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:387:17)
          at PacketParser.Connection.packetParser.p [as onPacket] (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:70:12)
          at PacketParser.executeStart (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/packet_parser.js:75:16)
          at Socket.Connection.stream.on.data (/Users/rehdie/development/projects/db-typescript/node_modules/mysql2/lib/connection.js:77:25)
          at Socket.emit (events.js:198:13)
          at addChunk (_stream_readable.js:288:12)
          at readableAddChunk (_stream_readable.js:269:11)
          at Socket.Readable.push (_stream_readable.js:224:10)
          at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  
    console.log node_modules/mysql2/lib/connection.js:395
      0 24 ==&gt; ClientHandshake#unknown name(5,maybeOK,29)
  
    console.log src/lib/mysql/driver/mysql-driver.ts:24
      Connection created =&gt; about to call connect()
  
  
   RUNS  src/tests/mysql/mysql-connection.spec.ts
  </code></pre>
  
  <p>When I perform a <code>show process list</code> in mysql, I see a new process with Command 'Sleep' (state is empty and info is null).</p>
  
  <p>Any ideas?</p>