Skip to content

server crashes on page load using custom server with compression #8408

Closed
@knight-of-zero

Description

@knight-of-zero

Bug report

Describe the bug

When using a custom server (e.g. Node's native http2), the server crashes after loading the first page. Error output is:

$ npm run dev

> with-http2@1.0.0 dev /home/username/next.js/with-http2-app
> node server.js

[ ready ] compiled successfully
[ wait ]  compiling ...
Listening on HTTPS port 3000
[ ready ] compiled successfully
[ event ] build page: /
[ wait ]  compiling ...
[ ready ] compiled successfully
/home/username/next.js/with-http2-app/node_modules/compression/index.js:84
        this._implicitHeader()
             ^

TypeError: this._implicitHeader is not a function
    at Http2ServerResponse.write (/home/username/next.js/with-http2-app/node_modules/compression/index.js:84:14)
    at ReadStream.ondata (_stream_readable.js:705:22)
    at ReadStream.emit (events.js:193:13)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:276:11)
    at ReadStream.Readable.push (_stream_readable.js:231:10)
    at fs.read (internal/fs/streams.js:183:12)
    at FSReqCallback.wrapper [as oncomplete] (fs.js:478:5)

To Reproduce

  1. Run npx create-next-app --example with-http2 with-http2-app
  2. Run cd with-http2-app
  3. Copy your SSL keys into localhost-privkey.pem and localhost-cert.pem.
  4. Run npm run dev
  5. Load https://localhost:3000/ in a browser and ignore the warning about self-signed certs.

I don't believe that this bug is limited to the example... but it's a good way to reproduce the issue. See "Additional context" for details.

Expected behavior

The server should stay up after responding.

System information

OS: Ubuntu 18.04.3 LTS.
Node: I reproduced this on both v11.15.0 and v8.16.1.
Next.js: v9.0.3

Additional context

Probably caused by: expressjs/compression#128
Probably introduced by: #8066

You can fix it by disabling compression:

const app = next({
  dev,
  conf: {
    compression: false,
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions