fix(firestore): fix fetch connection error message - #10340
Conversation
🦋 Changeset detectedLatest commit: 31fb267 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Code Review
This pull request improves error handling in FetchConnection for the browser-lite platform of Firestore by extracting more detailed error messages (including message and cause) when a fetch request fails. The review feedback points out a potential issue where err.message is undefined but err.cause is present, which would result in a string containing "undefined", and provides a code suggestion to handle this case safely.
MarkDuckworth
left a comment
There was a problem hiding this comment.
LGTM with question
| const cause = err?.cause ? String(err.cause) : undefined; | ||
| const errorMessage = | ||
| (message && cause ? `${message} (${cause})` : (message ?? cause)) ?? | ||
| err?.statusText ?? |
There was a problem hiding this comment.
I don't have enough context on statusText but are there scenarios where either message or cause is defined but statusText still provides useful information, and therefore this change is a regression in surfacing error details?
There was a problem hiding this comment.
Honestly, I don't think statusText was ever defined on the error object. I think this code was copied from the block above, and response.statusText (valid) was replaced with err.statusText by mistake.
Fixes fetch connection error messages. We now read the thrown error's
messageandcauseinstead of attempting to read a potentially non-existentstatusTextfrom anErrorobject, preventing connection failures likeECONNREFUSEDfrom being displayed asundefined.In tests, we see errors like this
Now, they will look like this:
This will also impact users.
Before:
Now: