Skip to content

Commit

Permalink
chore: support writableEnded (#1402)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinovyatkin authored and dead-horse committed Oct 15, 2019
1 parent b968688 commit f155785
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ module.exports = {

get writable() {
// can't write any more after response finished
if (this.res.finished) return false;
// response.writableEnded is available since Node > 12.9
// https://nodejs.org/api/http.html#http_response_writableended
// response.finished is undocumented feature of previous Node versions
// https://stackoverflow.com/questions/16254385/undocumented-response-finished-in-node-js
if (this.res.writableEnded || this.res.finished) return false;

const socket = this.res.socket;
// There are already pending outgoing res, but still writable
Expand Down

0 comments on commit f155785

Please sign in to comment.