From d141150e437833aff778ab70efa1df9bd1b72724 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 1 Aug 2018 18:49:00 +0200 Subject: [PATCH] Do not use `spdy` on Node 10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `spdy` is effectively unmaintained, and as a consequence of an implementation that extensively relies on Node’s non-public APIs, broken on Node 10 and above. In those cases, only https will be used for now. Once express supports Node's built-in HTTP/2 support, migrating over to that should be the best way to go. Fixes: https://github.com/webpack/webpack-dev-server/issues/1449 Fixes: https://github.com/nodejs/node/issues/21665 --- lib/Server.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Server.js b/lib/Server.js index 9f1992f733..c5402134ee 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -5,6 +5,7 @@ require('./polyfills'); const fs = require('fs'); const http = require('http'); +const https = require('https'); const path = require('path'); const url = require('url'); const chokidar = require('chokidar'); @@ -484,7 +485,20 @@ function Server(compiler, options, _log) { }; } - this.listeningApp = spdy.createServer(options.https, app); + // `spdy` is effectively unmaintained, and as a consequence of an + // implementation that extensively relies on Node’s non-public APIs, broken + // on Node 10 and above. In those cases, only https will be used for now. + // Once express supports Node's built-in HTTP/2 support, migrating over to + // that should be the best way to go. + // The relevant issues are: + // - https://github.com/nodejs/node/issues/21665 + // - https://github.com/webpack/webpack-dev-server/issues/1449 + // - https://github.com/expressjs/express/issues/3388 + if (+process.version.match(/^v(\d+)/[1]) >= 10) { + this.listeningApp = https.createServer(options.https, app); + } else { + this.listeningApp = spdy.createServer(options.https, app); + } } else { this.listeningApp = http.createServer(app); }