Skip to content

[SDK] fix: clear inflightRequests after each batch RPC call #5872

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

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Jan 2, 2025


[SDK] fix: clear inflightRequests after each batch RPC call

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): CORE-667

Notes for the reviewer

The inflightRequests map is not correctly cleared after each RPC call resulting in errors being cached indefinitely and a potential memory leak. This PR clears the inflightRequests map after each RPC call.

How to test

Running a similar patch on Engine and testing if RPC error responses are cached.


PR-Codex overview

This PR focuses on improving error handling and response management in the rpc.ts file. It enhances clarity in the flow by explicitly managing different response types and ensuring that inflight requests are correctly resolved or rejected.

Detailed summary

  • Updated comments for clarity regarding inflight request handling.
  • Changed the response handling logic to check for errors and strings more explicitly.
  • Modified rejection messages for unsupported subscription responses.
  • Introduced a finally block to clear the inflightRequests map after processing.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@arcoraven arcoraven requested review from a team as code owners January 2, 2025 02:47
Copy link

vercel bot commented Jan 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 3:01am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 3:01am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 3:01am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 3:01am

Copy link

changeset-bot bot commented Jan 2, 2025

⚠️ No Changeset found

Latest commit: 1b7604c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

graphite-app bot commented Jan 2, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jan 2, 2025
@arcoraven arcoraven changed the title fix: clear inflightRequests after each batch RPC call [SDK] fix: clear inflightRequests after each batch RPC call Jan 2, 2025
Copy link
Contributor

github-actions bot commented Jan 2, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 45.02 KB (-0.17% 🔽) 901 ms (-0.17% 🔽) 3.3 s (+3.08% 🔺) 4.2 s
thirdweb (cjs) 110.78 KB (-0.07% 🔽) 2.3 s (-0.07% 🔽) 8 s (+1.29% 🔺) 10.2 s
thirdweb (minimal + tree-shaking) 5.58 KB (-0.04% 🔽) 112 ms (-0.04% 🔽) 464 ms (-4.59% 🔽) 576 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 96 ms (+31.8% 🔺) 106 ms
thirdweb/react (minimal + tree-shaking) 19.11 KB (-0.06% 🔽) 383 ms (-0.06% 🔽) 1.1 s (+47.78% 🔺) 1.5 s

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 55.19%. Comparing base (a9547c5) to head (1b7604c).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
packages/thirdweb/src/rpc/rpc.ts 54.54% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5872   +/-   ##
=======================================
  Coverage   55.19%   55.19%           
=======================================
  Files        1123     1123           
  Lines       59622    59620    -2     
  Branches     5029     5032    +3     
=======================================
+ Hits        32906    32907    +1     
+ Misses      25996    25993    -3     
  Partials      720      720           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from a9547c5
packages 52.85% <54.54%> (+<0.01%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
packages/thirdweb/src/rpc/rpc.ts 71.42% <54.54%> (+1.79%) ⬆️

activeBatch.forEach((inflight, index) => {
// Handle the inflight request promise for each response.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes are just comments and re-arranging the if statements into if-else's.

Copy link
Contributor

@kien-ngo kien-ngo left a comment

Choose a reason for hiding this comment

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

lgtm

@gregfromstl gregfromstl merged commit 8f43aa7 into main Jan 3, 2025
30 of 31 checks passed
@gregfromstl gregfromstl deleted the ph/clearInflightRequests branch January 3, 2025 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants