From d2c9f12c3a3edb8e760749d000a583cf0e9a2b10 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Mon, 23 Jan 2023 13:02:58 +0000 Subject: [PATCH] if possible - force ipv4 name resolution to have priority to fix Issue #4010 and others (eg) email node server connect fails, and some reported on SO --- packages/node_modules/node-red/lib/red.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/node-red/lib/red.js b/packages/node_modules/node-red/lib/red.js index ddc140cc4..8ba46a2d3 100644 --- a/packages/node_modules/node-red/lib/red.js +++ b/packages/node_modules/node-red/lib/red.js @@ -25,9 +25,15 @@ var api = require("@node-red/editor-api"); var server = null; var apiEnabled = false; +const NODE_MAJOR_VERSION = process.versions.node.split('.')[0]; +if (NODE_MAJOR_VERSION > 14) { + const dns = require('node:dns'); + dns.setDefaultResultOrder('ipv4first'); +} + function checkVersion(userSettings) { var semver = require('semver'); - if (!semver.satisfies(process.version,">=8.9.0")) { + if (!semver.satisfies(process.version,">=12.0.0")) { // TODO: in the future, make this a hard error. // var e = new Error("Unsupported version of Node.js"); // e.code = "unsupported_version";