Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit 3f733f3

Browse files
author
Erik Benoist
authored
Merge pull request #1 from reverbdotcom/erik/2-node-10
Backports fix for webpack#1449
2 parents 7cdfb74 + 6f6b58a commit 3f733f3

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

lib/Server.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const historyApiFallback = require('connect-history-api-fallback');
1919
const selfsigned = require('selfsigned');
2020
const sockjs = require('sockjs');
2121
const spdy = require('spdy');
22+
const https = require('https');
2223
const webpack = require('webpack');
2324
const webpackDevMiddleware = require('webpack-dev-middleware');
2425
const OptionsValidationError = require('./OptionsValidationError');
@@ -481,7 +482,20 @@ function Server(compiler, options) {
481482
};
482483
}
483484

484-
this.listeningApp = spdy.createServer(options.https, app);
485+
// `spdy` is effectively unmaintained, and as a consequence of an
486+
// implementation that extensively relies on Node’s non-public APIs, broken
487+
// on Node 10 and above. In those cases, only https will be used for now.
488+
// Once express supports Node's built-in HTTP/2 support, migrating over to
489+
// that should be the best way to go.
490+
// The relevant issues are:
491+
// - https://github.com/nodejs/node/issues/21665
492+
// - https://github.com/webpack/webpack-dev-server/issues/1449
493+
// - https://github.com/expressjs/express/issues/3388
494+
if (+process.version.match(/^v(\d+)/)[1] >= 10) {
495+
this.listeningApp = https.createServer(options.https, app);
496+
} else {
497+
this.listeningApp = spdy.createServer(options.https, app);
498+
}
485499
} else {
486500
this.listeningApp = http.createServer(app);
487501
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "webpack-dev-server",
3-
"version": "2.11.3",
2+
"name": "@reverbdotcom/webpack-dev-server",
3+
"version": "2.11.3-node10-1",
44
"description": "Serves a webpack app. Updates the browser on changes.",
55
"license": "MIT",
66
"repository": "webpack/webpack-dev-server",

test/Https.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const request = require('supertest');
5+
const helper = require('./helper');
6+
const config = require('./fixtures/contentbase-config/webpack.config');
7+
require('mocha-sinon');
8+
9+
const contentBasePublic = path.join(__dirname, 'fixtures/contentbase-config/public');
10+
11+
describe('HTTPS', function testHttps() {
12+
let server;
13+
let req;
14+
afterEach(helper.close);
15+
16+
// Increase the timeout to 20 seconds to allow time for key generation.
17+
this.timeout(20000);
18+
19+
describe('to directory', () => {
20+
before((done) => {
21+
server = helper.start(config, {
22+
contentBase: contentBasePublic,
23+
https: true
24+
}, done);
25+
req = request(server.app);
26+
});
27+
28+
it('Request to index', (done) => {
29+
req.get('/')
30+
.expect(200, /Heyo/, done);
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)