fix(sdk): add optional chaining to getSpotMarketAccountAndSlot calls#2176
fix(sdk): add optional chaining to getSpotMarketAccountAndSlot calls#2176claygeo wants to merge 1 commit intodrift-labs:masterfrom
Conversation
getSpotMarketAccount() and forceGetSpotMarketAccount() access .data on the return value of getSpotMarketAccountAndSlot() without optional chaining. If the market index doesn't exist or the subscriber hasn't loaded yet, this crashes with "Cannot read properties of undefined." Closes drift-labs#2137
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdated Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Summary
Closes #2137
getSpotMarketAccount()andforceGetSpotMarketAccount()access.dataon the return value ofgetSpotMarketAccountAndSlot()without optional chaining. If the market index doesn't exist or the account subscriber hasn't loaded yet, this throws a runtime error.Fix
Both occurrences fixed:
getSpotMarketAccount()(line 699)forceGetSpotMarketAccount()(line 710)The return type is already
SpotMarketAccount | undefined, so callers already handle the undefined case.Summary by CodeRabbit