From afde4fe424698a94652e86768fba63afd5429e91 Mon Sep 17 00:00:00 2001 From: moky80 Date: Wed, 18 Sep 2024 16:28:59 +0200 Subject: [PATCH] forward exceptions on parsing incomping requests to the 'error' event to be handled by applications (fixed ERR_INVALID_HTTP_TOKEN) --- lib/http-proxy/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 977a4b362..afc26feff 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -78,8 +78,13 @@ function createRightProxy(type) { * refer to the connection socket * pass(req, socket, options, head) */ - if(passes[i](req, res, requestOptions, head, this, cbl)) { // passes can return a truthy value to halt the loop - break; + try { + if(passes[i](req, res, requestOptions, head, this, cbl)) { // passes can return a truthy value to halt the loop + break; + } + } catch ( e ) { + this.emit('error', e); + continue; } } };