Screen returned streams for setup errors
- Dominant language
- JavaScript
- Stars
- 14.8k
- Forks
- 1.4k
- Avg merge
- 22d 3h
- Merged PRs (30d)
- 1
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): no
#### Context
* *node version*: any
* *module version*: 20.0.3
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone
* *any other relevant information*:
#### What problem are you trying to solve?
Improved error response to initial `stream` response errors, as reported in #4199. Currently the connection is just forcefully disconnected.
#### Do you have a new or modified API suggestion to solve the problem?
Always waiting for a `'readable'` event before sending the headers is probably not something that we want to do, since it can delay sending the response headers, but it could work wonders as a (potentially default) option.
I don't know where this option would go, as it should probably be able to be specified inside the handler logic, and `h.response()` does not provide for options.
Come to think of it, it could just be added as a new toolkit method on `h`. Maybe `h.stream(stream, { immediate: false })`, similar to how inert provides a `h.file()`. Or it could be provided as a property on the stream object, like `stream.statusCode`.
Contributor guide
Assessment
This issue has not been assessed yet.