Skip to content

http2 stream.end error #36860

Open
Open
@ariran5

Description

@ariran5
  • Version: 15.5.1
  • Platform: Darwin MacBook-Pro.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

What steps will reproduce the bug?

// index.mjs

import http2 from 'http2'
import fs from 'fs'

const server = http2.createSecureServer({
  key: fs.readFileSync('localhost-privkey.pem'),
  cert: fs.readFileSync('localhost-cert.pem')
})

server.on('error', (err) => console.error(err))

server.on('stream', (stream, headers, flags) => {
  stream.end('qweqwe ds sdoapskd okqdoeik woik ed'.repeat(80), err => {
    if (err) {
      console.error(err) // always shows error on each request
      return
    }
    console.log('qweqwe')
  })
});

server.listen(8444) // https://localhost:8444
Error [ERR_STREAM_DESTROYED]: Cannot call end after a stream was destroyed
    at new NodeError (node:internal/errors:278:15)
    at errorBuffer (node:internal/streams/writable:527:14)
    at afterWrite (node:internal/streams/writable:507:5)
    at onwrite (node:internal/streams/writable:483:7)
    at done (node:internal/http2/core:2081:7)
    at WriteWrap.writeCallback [as callback] (node:internal/http2/core:2086:7)
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:89:12) {
  code: 'ERR_STREAM_DESTROYED'
}

What is the expected behavior?

Works without errors

What do you see instead?

Always shows errors on each response in stream.end callback

Metadata

Metadata

Assignees

No one assigned

    Labels

    http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions