fix: possible HPE_INVALID_CONSTANT in console
Massimo Melina committed
Mar 20, 2026 at 14:41 UTC
b396da453950f73492b8684fd29e7538eca1d442
1 file changed
+1
-3
src/index.ts
+1
-3
@@ -64,9 +64,7 @@ function errorHandler(err:Error & { code:string, path:string }) {
64
if (code === 'ECANCELED' || code === 'ECONNRESET' || code === 'ECONNABORTED' || code === 'EPIPE'
65
|| code === 'ERR_STREAM_WRITE_AFTER_END' // happens disconnecting uploads, don't care
66
|| code === 'ERR_STREAM_PREMATURE_CLOSE' // happens when many files are sent (not locally), but I checked that the files are written completely. Introduced after node18.5.0 and is thrown by pipeline() used by PUT method handler.
67
- || code === 'HPE_INVALID_METHOD' // cannot serve you like that
68
- || code === 'HPE_CLOSED_CONNECTION' // uploads with wrong content-length, but we already handle that properly
69
- || code === 'HPE_INVALID_EOF_STATE') return // someone interrupted, don't care
67
+ || code.startsWith('HPE')) return // malformed client/probe HTTP parser errors, not internal failures
68
console.error('server error', err)
69
}
70