Skip to content

Commit f208db7

Browse files
aidantruyadorno
authored andcommitted
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. PR-URL: #45420 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1ce2f56 commit f208db7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/_http_client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ function ClientRequest(input, options, cb) {
173173

174174
if (options.path) {
175175
const path = String(options.path);
176-
if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null)
176+
if (RegExpPrototypeExec(INVALID_PATH_REGEX, path) !== null) {
177+
debug('Path contains unescaped characters: "%s"', path);
177178
throw new ERR_UNESCAPED_CHARACTERS('Request path');
179+
}
178180
}
179181

180182
if (protocol !== expectedProtocol) {

0 commit comments

Comments
 (0)