Skip to content

Commit f155785

Browse files
tinovyatkindead-horse
authored andcommitted
chore: support writableEnded (#1402)
1 parent b968688 commit f155785

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/response.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,11 @@ module.exports = {
520520

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

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

0 commit comments

Comments
 (0)