question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mysql2 reports EPIPE error instead of ER_BAD_FIELD_ERROR

See original GitHub issue

I’m using mysql2 in knex, which in turn is used in a bookshelf model.

When I attempt to insert a model that has a field that doesn’t exist in the table mysql2 returns this error:

{ [Error: insert into `test_table` (`create_time`, `text1`, `text2`, `text3`, `text4`, `nonexistent_column`, `text5`) values ('2016-05-04 15:52:17.174', 'http://google.com', '2016-05-04 15:52:11.512', 'http://yahoo.com', 2, 3, 1
) - This socket has been ended by the other party] code: 'EPIPE', fatal: true }

However, given the exact same scenario but using mysql instead the error is:

[Error: insert into `test_table` (`create_time`, `text1`, `text2`, `text3`, `text4`, `nonexistent_column`, `text5`) values ('2016-05-04 16:05:54.726', 'http://google.com', '2016-05-04 16:05:46.093', 'http://yahoo.com', 2, 3, 1
) - ER_BAD_FIELD_ERROR: Unknown column 'nonexistent_column' in 'field list']

This is incredibly misleading and I’m not sure why EPIPE is returned by mysql2 (or maybe it’s knex?).

mysql2 version is 1.0.0-rc.1. mysql version is 2.10.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
diversariocommented, May 13, 2016

FYI, this what it turned out to be https://github.com/felixge/node-mysql/issues/1411

Connection was lost due to db failover and the pool library that knex uses didn’t reacquire one automatically.

1reaction
diversariocommented, May 5, 2016

Sure!

The table is as follows:

CREATE TABLE `test_table` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `text5` int(10) unsigned NOT NULL,
  `text4` int(10) unsigned NOT NULL,
  `text1` text,
  `text3` text,
  `text2` datetime NOT NULL,
  `create_time` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_text5` (`text5`),
  KEY `ix_text4` (`text4`),
  KEY `ix_create_time` (`create_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4

and data being inserted is

{
  text5: 1,
  text4: 2,
  text1: 'http://google.com',
  text3: 'http://yahoo.com',
  nonexistent_column: 3,
  text4: new Date()
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Maximum query length to avoid EPIPE error in node.js
I had this issue just now and it turned out that the Mysql server I was talking to (it was on Amazon RDS)...
Read more >
what is a "write EPIPE" error? - Google Groups
Any ideas on what I'm doing wrong? EPIPE means that writing of (presumably) the HTTP request failed because the other end closed the...
Read more >
write EPIPE error on generating html to pdf
Hi Team, I'm trying to generate html to pdf using html-pdf npm . Please check below code const invoicePath = path.resolve(path.join(__dirname,
Read more >
mysql2 - npm
fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS. Latest version: 2.3.3, last published: a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found