Skip to content

Commit 8ab9eb6

Browse files
addaleaxmichael-ciniawsky
authored andcommitted
fix(Server): don't use spdy on node >= v10.0.0 (#1451)
1 parent 4740224 commit 8ab9eb6

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

‎lib/Server.js‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const path = require('path');
1515
constip=require('ip');
1616
consturl=require('url');
1717
consthttp=require('http');
18+
consthttps=require('https');
1819
constspdy=require('spdy');
1920
constsockjs=require('sockjs');
2021

@@ -571,7 +572,20 @@ function Server (compiler, options = {}, _log) {
571572
};
572573
}
573574

574-
this.listeningApp=spdy.createServer(options.https,app);
575+
// `spdy` is effectively unmaintained, and as a consequence of an
576+
// implementation that extensively relies on Node’s non-public APIs, broken
577+
// on Node 10 and above. In those cases, only https will be used for now.
578+
// Once express supports Node's built-in HTTP/2 support, migrating over to
579+
// that should be the best way to go.
580+
// The relevant issues are:
581+
// - https://github.com/nodejs/node/issues/21665
582+
// - https://github.com/webpack/webpack-dev-server/issues/1449
583+
// - https://github.com/expressjs/express/issues/3388
584+
if(+process.version.match(/^v(\d+)/)[1]>=10){
585+
this.listeningApp=https.createServer(options.https,app);
586+
}else{
587+
this.listeningApp=spdy.createServer(options.https,app);
588+
}
575589
}else{
576590
this.listeningApp=http.createServer(app);
577591
}

‎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+
constpath=require('path');
4+
constrequest=require('supertest');
5+
consthelper=require('./helper');
6+
constconfig=require('./fixtures/contentbase-config/webpack.config');
7+
require('mocha-sinon');
8+
9+
constcontentBasePublic=path.join(__dirname,'fixtures/contentbase-config/public');
10+
11+
describe('HTTPS',functiontestHttps(){
12+
letserver;
13+
letreq;
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)