undici icon indicating copy to clipboard operation
undici copied to clipboard

Unprecise error message on fetch() to an endpoint with a certificate which was signed by an "unkown" CA

Open bewue opened this issue 2 years ago • 5 comments

Bug Description

There is a unprecise error message ("fetch failed") on fetch() to an endpoint with a certificate which was signed by an "unkown" CA. If its an custom or internal CA, the fetch() will fail, that seems correct, but the error message ist absolut unprecise. It is therefore very difficult to find the cause.

Reproducible By

fetch() to an enpoint with a certificate which was signed by an "unkown" CA.

An "unkown" CA seems to be an CA which not exist in the default search path for CAs of node. By default node seem to use CA-certificates baked in the build.

Expected Behavior

A useful error message is shown.

Logs & Screenshots

TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11576:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) ...

Environment

Ubuntu 22.04 Node v18.17.0

bewue avatar Jul 28 '23 12:07 bewue

Does the spec say that we cannot extend the error for a fetch failure, not even through the cause option while constructing the error?

Just checking out as it seems quite often to issues like this are open where the error is hard to understand.

cc: @KhafraDev @ronag

metcoder95 avatar Jul 28 '23 16:07 metcoder95

I think cause is fine.

ronag avatar Jul 28 '23 16:07 ronag

cause is fine. The error message is fine too and should be kept.

KhafraDev avatar Jul 28 '23 16:07 KhafraDev

Do I understand you correctly that you think the error message "fetch error" is appropriate here? The user is helpless with this error message!

edit: maybe i misunderstood you and you are talking about displaying more information in the stacktrace. that would be useful :)

bewue avatar Jul 28 '23 18:07 bewue

Do I understand you correctly that you think the error message "fetch error" is appropriate here? The user is helpless with this error message!

That's the WHATWG specification for fetch(). There is a cause property on the error that reports the actual error that happened.

(unless you are doing cross-platform or isomorphic code, you might have a better experience with undici.request() or good old http.request()).

mcollina avatar Jul 28 '23 21:07 mcollina