From fd69cd10d3c424ebe21f458d9606961b2fa30717 Mon Sep 17 00:00:00 2001 From: aidant <15520814+aidant@users.noreply.github.com> Date: Fri, 11 Nov 2022 16:04:25 +1100 Subject: [PATCH] http: add debug log for ERR_UNESCAPED_CHARACTERS When encountering ERR_UNESCAPED_CHARACTERS on large applications it can be unclear which request has caused this error. Even when setting NODE_DEBUG=http there is no information about this error since it's thrown before any debug logs. This patch adds a debug log that contains the invalid path. --- lib/_http_client.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index ef58f66f6a97e5..79ed2c8bc9b2d3 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -173,8 +173,10 @@ function ClientRequest(input, options, cb) { if (options.path) { const path = String(options.path); - if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null) + if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null) { + debug('Path contains unescaped characters: "%s"', path); throw new ERR_UNESCAPED_CHARACTERS('Request path'); + } } if (protocol !== expectedProtocol) {