test-server-timeout-disconnect.js 549 B

12345678910111213141516171819202122232425
  1. var common = require('../../common');
  2. var connection = common.createConnection();
  3. var assert = require('assert');
  4. connection.query('SET wait_timeout = 1');
  5. var errorErr;
  6. var endErr;
  7. connection
  8. .on('end', function(err) {
  9. assert.ok(!endErr);
  10. endErr = err;
  11. })
  12. .on('error', function(err) {
  13. assert.ok(!errorErr);
  14. errorErr = err;
  15. });
  16. process.on('exit', function() {
  17. assert.strictEqual(errorErr.code, 'PROTOCOL_CONNECTION_LOST');
  18. assert.strictEqual(errorErr.fatal, true);
  19. assert.strictEqual(endErr, errorErr);
  20. });