fix: correctly set default retry params#394
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe SDK's ChangesDefault Retry Configuration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes the SDK’s default retry behavior so that retryParams are correctly initialized even when not explicitly provided, and updates tests to cover the default-retry scenario and correct a previously-broken 429 retry test matcher.
Changes:
- Initialize
Configuration.retryParamsby mergingGetDefaultRetryParams()with user-provided overrides. - Add a new test case validating that a 429 followed by success is retried when using default retry configuration.
- Fix the 429 retry test’s nock request body matcher to include
authorization_model_id.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
configuration.ts |
Ensures default retry parameters are applied when retryParams are omitted. |
tests/index.test.ts |
Adds/adjusts 429 retry tests to validate default retry behavior and correct request matching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e9cd6fa to
6b08e4a
Compare
SoulPancake
left a comment
There was a problem hiding this comment.
Thanks a lot @kamilogorek !
There was a problem hiding this comment.
One small follow-up: this exposes a failure in tests/client.test.ts › ListRelations › should throw an error if any check returns an error. With retries now actually applied, scope3 mocks the 500 only once, the SDK retries, and the retry has no interceptor,,so the error goes through the network-error branch in common.ts and gets wrapped as a plain FgaError instead of FgaApiError.
Two small asks:
Mock the 500 DefaultMaxRetry + 1 times in that test. That way the test exercises the actual production path (transient 5xx → retried → exhausted → FgaApiInternalError)
Move nock.disableNetConnect() from client.test.ts into tests/setup.ts so that unmatched requests fail everywhere
Happy to push onto your branch if easier.
Thanks again
|
No worries, I missed to run tests after follow-up change, my bad. |
|
Follow-up cleanup PR #395 |
|
Thanks a lot |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #394 +/- ##
==========================================
- Coverage 85.82% 85.59% -0.24%
==========================================
Files 26 26
Lines 1270 1270
Branches 250 226 -24
==========================================
- Hits 1090 1087 -3
Misses 110 110
- Partials 70 73 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Anytime. #395 has also been rebased and tests are all green locally 🫡 |
Well, it won't as of today 😅
This has been never caught because you always override
retryParamsfor every test client.Also
"429 with retry in config and retry is successful"test was broken, because nock body matcher was incorrect, so it was skipped, making200response always evaluate first, skipping a retry entirely.Summary by CodeRabbit