node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

keepalive not behaving as documented

Open mrx8 opened this issue 2 years ago • 3 comments

according to the commit: https://github.com/sidorares/node-mysql2/commit/6b59a3604a53a7f85c8392fcb9577aabbd1eb4df keepalive is now always on. It cannot be disabled. The inline-documentation erroneously says it is off by default. I have a problem with this in combination with the libkeepalive-library and need to disable it. Is it possible to integrate the possibility to disable keepalive in mysql2 once more ?

mrx8 avatar Jun 14 '22 15:06 mrx8

hm, the change looks quite out of sync with the comments, I might need to re-read communication leading to in https://github.com/sidorares/node-mysql2/pull/1081

@benbotto can you comment?

sidorares avatar Jun 20 '22 00:06 sidorares

I think this is a bug--true shouldn't be hard coded in the call to setKeepAlive. Seems like #1081 had the right logic, but in #1086 I erroneously removed the if (this.config.enableKeepAlive) check.

#1258 seems to correct the issue, mostly, but there's a comment on Pool.d.ts about a bad type. Also might want a !! on https://github.com/sidorares/node-mysql2/pull/1258/files#diff-1978d11697f58179bc32b66c6ac7f21cbdfd6649a8f013248a1f9feee25858feR99

    this.enableKeepAlive =
      options.enableKeepAlive === undefined || !!options.enableKeepAlive;

Not sure why #1258 was closed.

benbotto avatar Jun 21 '22 15:06 benbotto

@kn3ny are you keen to finish that work? The PR looks mostly ready, happy to merge it but if you still plan to make a fresh one let us know

sidorares avatar Jun 22 '22 00:06 sidorares

I've just created PR #2016 to fix this.

n0v1 avatar May 17 '23 09:05 n0v1