Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 909 Bytes

README.md

File metadata and controls

37 lines (25 loc) · 909 Bytes

Node MySQL Early Exit

Demo of the early exit when calling connection.end() with a running query.

Setup

  1. Install dependencies

    yarn
  2. Start & setup database with docker-compose

    docker-compose up -d
    docker-compose exec mysql sh -c 'exec mysql -uroot -p"supersecret" < /sql/authors.sql'

Problem behavior

MYSQL_PASSWORD=supersecret node ./mysql-early-exit.js --no-process-results

Notice you never see Disconnected, THIS IS NEVER SHOWN printed to the console. The last line of the code prints this message. Somehow it's skipped. It seems like something is calling exit(0) behind the scenes when there are leftover open streams during a disconnect.

Expected Behaviour

MYSQL_PASSWORD=supersecret node ./mysql-early-exit.js --process-results

Notice that Disconnected, THIS IS NEVER SHOWN was printed to the console.