From 7a25aa7e7fc535cc47b96a67727cd0bfc0b42fe2 Mon Sep 17 00:00:00 2001 From: animetosho Date: Wed, 23 Dec 2020 16:09:55 +1000 Subject: [PATCH] Work around nodejs bug with 'onread' handler https://github.com/nodejs/node/pull/32590 --- lib/nntp.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nntp.js b/lib/nntp.js index e1efb02..f6f4f1d 100644 --- a/lib/nntp.js +++ b/lib/nntp.js @@ -82,7 +82,11 @@ function NNTP(opts) { this._connectRetries = opts.connectRetries; var connectOpts = opts.connect; - var supportsOnread = /^v(12\.1\d|1[3-9]|[2-9]\d|\d\d\d)\./.test(process.version); // test if node >= 12.10.0 + // although the feature was added in node 12.10.0, it's crashy on Linux until 13.13.0 / 12.16.3 + var supportsOnread = ( + +process.version.replace(/\.\d+$/, '').replace(/^v/, '') >= 13.13 + || /^v12\.(16\.[3-9]|1[789]\.|[2-9]\d\.)/.test(process.version) + ); if(supportsOnread || !opts.connect.port) { connectOpts = util.extend({}, opts.connect); this.opts = util.extend({}, this.opts, {connect: connectOpts});