Title: http.Server is not able to handle RST packets and emits clientError · Issue #33302 · nodejs/node · GitHub
Open Graph Title: http.Server is not able to handle RST packets and emits clientError · Issue #33302 · nodejs/node
X Title: http.Server is not able to handle RST packets and emits clientError · Issue #33302 · nodejs/node
Description: Version: v12.16.1 (but I've also experienced this with latest master) Platform: macOS 10.15.4 - Darwin ** 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64 Subsystem: http and/...
Open Graph Description: Version: v12.16.1 (but I've also experienced this with latest master) Platform: macOS 10.15.4 - Darwin ** 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RE...
X Description: Version: v12.16.1 (but I've also experienced this with latest master) Platform: macOS 10.15.4 - Darwin ** 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~1...
Opengraph URL: https://github.com/nodejs/node/issues/33302
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http.Server is not able to handle RST packets and emits clientError","articleBody":"* **Version**: v12.16.1 (but I've also experienced this with latest master)\r\n* **Platform**: macOS 10.15.4 - Darwin ** 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64\r\n* **Subsystem**: http and/or net\r\n\r\n### What steps will reproduce the bug?\r\n\r\n1. Start the following node.js application:\r\n\r\n```javascript\r\n'use strict';\r\n\r\nconst { createServer } = require('http');\r\n\r\nconst server = createServer((req, res) => {\r\n res.writeHead(200, {'Content-Length': 2}).end('OK');\r\n})\r\n\r\nserver.on('clientError', (err, socket) => {\r\n console.log('CLIENT ERROR');\r\n socket.end('HTTP/1.1 400 Bad Request\\r\\n\\r\\n');\r\n});\r\n\r\nserver.listen(8331);\r\n```\r\n\r\n2. Start a haproxy instance with the following configuration:\r\n\r\n```\r\nglobal\r\n log stdout format raw local1\r\n maxconn 4096\r\n\r\ndefaults\r\n log global\r\n mode http\r\n option httplog\r\n option dontlognull\r\n option forwardfor\r\n retries 3\r\n option redispatch\r\n maxconn 2000\r\n timeout connect 5000\r\n timeout client 50000\r\n timeout server 50000\r\n\r\nfrontend proxy\r\n bind 0.0.0.0:8330\r\n default_backend fastify\r\n\r\nbackend fastify\r\n server local 127.0.0.1:8331\r\n```\r\n\r\n3. Make several (usually two or three within the same terminal in the timespan of few seconds is enought) HTTP requests to the haproxy endpoint (`http://127.0.0.1:8330/check`)\r\n\r\n4. Note that random `CLIENT ERROR` logs will be shown on the Node.js server output, which is a indication that `clientError` is emitted. Note that the client side of the connection (in this case haproxy) has already received the 200 response, so the clientError handler data is never actually received.\r\n\r\n5. (optional) If you run tcpdump on port 8331 (the Node.js one) you will see that Node is not sending FIN and neither haproxy. Moreover at some point haproxy sends RST and this cause Node.js to emit the clientError.\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\nAs said above, triggering multiple request in short timeframe is enough.\r\n\r\nAnother way is to add `option http-server-close` to haproxy to force a `Connection: close`. This will emit the error on each request.\r\n\r\n### What is the expected behavior?\r\n\r\nNode.js should correctly handle connection terminated via RST (probably ignoring them) without emitting an error.\r\n\r\n### What do you see instead?\r\n\r\nNode.js emits a clientError when receiving a RST packet.","author":{"url":"https://github.com/ShogunPanda","@type":"Person","name":"ShogunPanda"},"datePublished":"2020-05-08T07:21:42Z","url":"https://github.com/nodejs/node/issues/33302"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a917e1af-b9e1-9b37-a054-363be5ba9c75 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 857C:2529CF:7B27BE:A67312:6AED2C12 |
| html-safe-nonce | 6bdd138ada4f2a41dd6e510ca14e092ce460c6dc67b990a243dbad81959a9f57 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTdDOjI1MjlDRjo3QjI3QkU6QTY3MzEyOjZBRUQyQzEyIiwidmlzaXRvcl9pZCI6IjI0MzM0MjI5NTcyNDU5NjczNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2666e31ea695c0c8f126ed1cc3b8a15e180c4aed6e4275dcb596e5e960ec7d23 |
| hovercard-subject-tag | issue:614559027 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/33302/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db65e344d4b0913b3f5779968abc2f500f847c555d27c42a01deb0ee1bbcf4ac/nodejs/node/issues/33302 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db65e344d4b0913b3f5779968abc2f500f847c555d27c42a01deb0ee1bbcf4ac/nodejs/node/issues/33302 |
| og:image:alt | Version: v12.16.1 (but I've also experienced this with latest master) Platform: macOS 10.15.4 - Darwin ** 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ShogunPanda |
| hostname | github.com |
| expected-hostname | github.com |
| None | e51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 59ebb7b901cc154ecc179a44f266fcf69f343b30 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width