-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Description
Bug report
Describe the bug
After upgrading from next.js v9.3.3 to v9.3.4, my production application will no longer run. This is because I'm using a custom http2 server and version 9.3.4 seems to be embedding a custom copy of the compression npm module which doesn't support http2 servers. The error printed is:
2020-04-04 20:20:26.150: (node:5938) UnhandledPromiseRejectionWarning: TypeError: this._implicitHeader is not a function
2020-04-04 20:20:26.150: at Http2ServerResponse.end (/var/www/mysite/node_modules/next/dist/compiled/compression/index.js:1:156302)
2020-04-04 20:20:26.150: at Object.onerror (/var/www/mysite/node_modules/koa/lib/context.js:157:9)
2020-04-04 20:20:26.150: at onerror (/var/www/mysite/node_modules/koa/lib/application.js:163:32)
2020-04-04 20:20:26.151: (node:5938) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
This is caused by this well-known bug: expressjs/compression#155 and I've worked around this before in my app by manually using that PR as my dependency instead of the official compression package, however, it looks like next.js is now embedding it's own copy of compression somewhere in /dist/compiled/compression which causes my site to break.
To Reproduce
Run a barebones Next.js app but with a custom server that uses the http2 module like this:
import http from 'http';
import https from 'https';
import Koa from 'koa';
import koaConnect from 'koa-connect';
import next from 'next';
import Router from 'koa-router';
const app = next();
const handle = app.getRequestHandler();
app.prepare().then((): any => {
const server = new Koa();
const router = new Router();
router.all('*', async (ctx: any) => {
await handle(ctx.req, ctx.res);
ctx.respond = false;
});
server.use(router.routes());
// Handle HTTPS connections with HTTP/2
const http2Server = http2.createSecureServer({
allowHTTP1: true,
}, server.callback());
// Handle HTTPS connections
return http2Server.listen(443, (err: Error) => {
if (err) throw err;
console.log('Listening for http2 requests on 443');
});Expected behavior
The app should still run without any error.
Screenshots
N/A
System information
- OS: All
- Browser (if applies) N/A
- Version of Next.js: 9.3.4