Repository navigation
fix(core): keep the original error as cause on FetchError - #168
Merged
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Member
Author
Research ReviewVerified
Adjacent Stubs Detected
Orphaned Files Detected
Escape Hatch Coverage
Object Shape Verification
Contract diff
Impact Analysis
Risks Not Tested
Research Suggestions
VerdictNo blocking issues found. Reviewed by PR Research Validator. This review checks whether code is based on verified sources rather than assumptions. |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createFetchcaught non-FetchErrorfailures (e.g. undiciTypeError: fetch failed) and rethrew aFetchErrorwith only the message, losingcause.code(ECONNRESET,UND_ERR_SOCKET).FetchErrornow accepts an optionalcauseand the catch block passes the original error.Closes Eyevinn/osaas-ai#2476
Part of Eyevinn/osaas-ai#2462
Changes
packages/core/src/fetch.ts: constructor takes{ message, httpCode, cause };super(message, cause === undefined ? undefined : { cause })(guarded, because{ cause: undefined }would create an own property). Catch block passescause: error. HTTP error paths unchanged.packages/core/src/fetch.test.ts: AC1 (TypeError with ECONNRESET cause), AC2 (string rejection), AC3 (400 text, no owncause), all withawait expect(...).rejects; the old error test, which passed when nothing threw, is rewritten.Consumer impact
messageandhttpCodeare unchanged.causeis a non-enumerable own property, soJSON.stringify(err)and enumerable-key consumers are unchanged. GreppedFetchErrorin packages cli, core, web and transcode (packages/*/src);packages/web/src/mypage.tsleft alone as specified. A consumer outside this repo would not be found by that search.Lessons
new Error('x', { cause: undefined })still creates an owncauseproperty, so the constructor must only pass options when a cause exists. The pre-existing error test used try/catch withoutrejectsand would pass even if nothing threw.What a human does next: on
mainofEyevinnOSC/client-tsrunnpm run lerna:versionand push (expect a version above 0.28.0, probably 0.29.0, which also ships PRs 165 and 166). Test:cd "$(mktemp -d)" && npm pack @osaas/client-core@latest --silent >/dev/null && tar -xzOf osaas-client-core-*.tgz package/lib/fetch.js | grep -c causeprints a number above 0. Releasing/publishing is birme's.🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com