Repository navigation
test(sdk): build the fetch stub's promise with Promise.try - #288
Merged
Merged
Conversation
Sonar's S4634 flagged the executor #287 wrote to clear S7503: a new Promise whose executor only calls resolve reads as a trivial promise. The executor existed only so a throwing handler rejects instead of throwing at the call. Promise.try does exactly that, calling the handler at once and turning a throw into a rejection, with no executor. Promise.resolve(handler(...)) would not: the throw escapes the call, and the throwing-handler test fails with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
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.



Summary
Clears the one Sonar issue open on
main: S4634 ("replace this trivial promise with Promise.resolve") insdks/typescript/src/test-support/global-fetch-stub.ts. #287 wrote that executor to clear S7503; Sonar then read it as a trivial promise.The executor exists only so a throwing handler rejects instead of throwing at the call, as the real
fetchdoes.Promise.try(handler, url, init)keeps exactly that behaviour: it calls the handler at once and turns a throw into a rejection, with no executor. Sonar's own suggestion,Promise.resolve(handler(...)), would not keep it.Verification
bun run typecheckandbun run lint: clean. The SDK targets ESNext with TypeScript 7, and Bun 1.3.14 hasPromise.try.bun test sdks/typescript/src/test-support sdks/typescript/src/connector-kit: 127 pass, 0 fail.Promise.resolve(handler(url, init))in its place, the test "a throwing handler rejects the returned promise instead of throwing at the call" fails.Test-support code only: it is excluded from
tsconfig.build.json, so nothing published changes.🤖 Generated with Claude Code
Summary by CodeRabbit