GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add note about clientError writable handling · nodejs/node@b41affb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • http.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+15Lines changed: 15 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,21 @@ ensure the response is a properly formatted HTTP response message.
10371037
correctly;
10381038
* `rawPacket`: the raw packet of current request.
10391039

1040+
In some cases, the client has already received the response and/or the socket
1041+
has already been destroyed, like in case of `ECONNRESET` errors. Before
1042+
trying to send data to the socket, it is better to check that it is still
1043+
writable.
1044+
1045+
```js
1046+
server.on('clientError', (err, socket) => {
1047+
if (err.code === 'ECONNRESET' || !socket.writable) {
1048+
return;
1049+
}
1050+
1051+
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
1052+
});
1053+
```
1054+
10401055
### Event: `'close'`
10411056
<!-- YAML
10421057
added: v0.1.4

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.