Skip to content

Commit 0867f72

Browse files
committed
More clearly expose OpenSSL 'unsupported' upstream errors
1 parent d0b3c2d commit 0867f72

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/rules/requests/request-handlers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,15 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
11271127
}
11281128
})().catch(reject)
11291129
).catch((e: ErrorLike) => {
1130+
if (!e.code && e.message === 'unsupported' && e.stack?.includes('node:internal/tls/secure-context')) {
1131+
// When something totally unsupported by OpenSSL is used, we get their weird and useless
1132+
// error - without codes or anything. We reformat it here mildly to make that at least
1133+
// a tiny bit clearer.
1134+
e.code = 'ERR_TLS_CONTEXT_UNSUPPORTED';
1135+
e.message = "Unsupported TLS configuration";
1136+
clientRes.tags.push('passthrough-tls-error:context-unsupported');
1137+
}
1138+
11301139
// All errors anywhere above (thrown or from explicit reject()) should end up here.
11311140

11321141
// We tag the response with the error code, for debugging from events:

0 commit comments

Comments
 (0)