Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk-router): quote unmarshall hotfix [SLT-302] #3223

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Oct 3, 2024

Description
A clear and concise description of the features you're adding in this pull request.

Additional context
Add any other context about the problem you're solving.

Metadata

  • Fixes #[Link to Issue]

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling and logging for fetching quotes, ensuring better visibility of issues.
    • Enhanced unmarshalling process to prevent failures from individual quote errors, returning null for unsuccessful unmarshalling.
  • Chores

    • Cleaned up the final list of quotes to remove any null values, ensuring only valid quotes are returned.

Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

The changes in this pull request focus on enhancing the getAllQuotes function within the packages/sdk-router/src/rfq/api.ts file. Key modifications include improved error handling and logging during the fetching and unmarshalling processes of quotes. An error message is logged for unsuccessful fetch responses, and a try-catch block is implemented around the unmarshalling to handle individual errors gracefully. Any null values resulting from unmarshalling errors are filtered out before returning the final list of quotes.

Changes

File Path Change Summary
packages/sdk-router/src/rfq/api.ts Enhanced error handling and logging in getAllQuotes. Added logging for fetch errors and unmarshalling errors. Returned null for failed unmarshalling and filtered out null values from the final quotes list.

Possibly related PRs

Suggested labels

javascript, M-synapse-interface, Sol, Typescript

Suggested reviewers

  • aureliusbtc
  • bigboydiamonds
  • trajan0x

🐇 In the meadow where quotes abound,
A function improved, new errors unbound.
With logs to guide through the fetch and the catch,
Nulls filtered away, a seamless match!
Hooray for the changes, let joy take flight,
In the world of SDK, everything's bright! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
packages/sdk-router/src/rfq/api.ts (2)

36-45: Enhanced quote processing with individual error handling.

The changes to quote processing are beneficial:

  1. Error handling for individual quotes prevents a single bad quote from causing the entire operation to fail.
  2. Filtering out null values ensures only valid quotes are returned.

These improvements make the function more robust and reliable.

Consider using Array.prototype.flatMap for a more concise implementation:

return quotes.flatMap((quote) => {
  try {
    return [unmarshallFastBridgeQuote(quote)];
  } catch (error) {
    console.error('Error unmarshalling quote:', error);
    return [];
  }
});

This approach combines the mapping and filtering steps, potentially improving readability and performance.


Line range hint 23-49: Consider additional improvements for robustness and observability.

While the current changes significantly improve the function, consider the following enhancements:

  1. Add more detailed logging, including request parameters and partial response data when available.
  2. Implement retry logic for transient failures.
  3. Add telemetry to track the success rate and performance of quote fetching and unmarshalling.

These suggestions could further improve the reliability and maintainability of the function. Would you like me to provide code examples for any of these improvements?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9c1dc5b and 142159d.

📒 Files selected for processing (1)
  • packages/sdk-router/src/rfq/api.ts (1 hunks)
🔇 Additional comments (2)
packages/sdk-router/src/rfq/api.ts (2)

31-33: Improved error logging for API response issues.

The addition of error logging for non-OK responses is a good improvement. It provides more context for debugging API-related issues.


47-49: Added error logging for fetch-related issues.

The addition of error logging for fetch-related issues is a good improvement. It enhances the observability of network or other fetch-related problems.

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 142159d
Status: ✅  Deploy successful!
Preview URL: https://f4c4bbea.sanguine-fe.pages.dev
Branch Preview URL: https://fix-sdk-unmarshall-hotfix.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@5828553). Learn more about missing BASE report.
Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master       #3223   +/-   ##
============================================
  Coverage          ?   90.63415%           
============================================
  Files             ?          54           
  Lines             ?        1025           
  Branches          ?          82           
============================================
  Hits              ?         929           
  Misses            ?          93           
  Partials          ?           3           
Flag Coverage Δ
packages 90.63415% <100.00000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChiTimesChi ChiTimesChi changed the title fix(sdk-router): quote unmarshall hotfix fix(sdk-router): quote unmarshall hotfix [SLT-302] Oct 3, 2024
@ChiTimesChi ChiTimesChi merged commit e88685f into master Oct 3, 2024
36 checks passed
@ChiTimesChi ChiTimesChi deleted the fix/sdk-unmarshall-hotfix branch October 3, 2024 21:22
Copy link

codecov bot commented Oct 3, 2024

Bundle Report

Changes will increase total bundle size by 6.65MB (18.66%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
sdk-router-@synapsecns/sdk-router-esm 255.08kB 426 bytes (0.17%) ⬆️
sdk-router-@synapsecns/sdk-router-cjs 117.47kB 234 bytes (0.2%) ⬆️
explorer-ui-server-cjs* 866.14kB 76 bytes (0.01%) ⬆️
explorer-ui-client-array-push* 2.31MB 152 bytes (0.01%) ⬆️
synapse-interface-client-array-push* 7.28MB 746 bytes (0.01%) ⬆️
synapse-interface-server-cjs* 1.64MB 147.92kB (9.9%) ⬆️⚠️
widget-cjs-esm* 271.27kB 2.03kB (-0.74%) ⬇️
docs-bridge-client-array-push* 10.57MB 2.67MB (33.79%) ⬆️⚠️
docs-bridge-server-cjs* 18.36MB 3.49MB (23.43%) ⬆️⚠️
synapse-constants-esm-cjs* 174.63kB 174.63kB (100%) ⬆️⚠️
synapse-constants-cjs-esm* 174.18kB 174.18kB (100%) ⬆️⚠️

ℹ️ *Bundle size includes cached data from a previous commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant