-
Notifications
You must be signed in to change notification settings - Fork 31
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: don't close used mock agent #170
Conversation
avoid ClientDestroyedError ```bash ClientDestroyedError: The client is destroyed at Agent.dispatch (node_modules/undici/lib/dispatcher-base.js:172:15) at MockAgent.dispatch (node_modules/undici/lib/mock/mock-agent.js:65:25) at MockAgent.request (node_modules/undici/lib/api/api-request.js:169:10) ```
WalkthroughThis update refactors the Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant App
participant MockAgent
participant Cluster
participant MM
User ->> App: Call restore()
App ->> Cluster: Call restore()
Cluster -->> App: Restoration done
App ->> MockAgent: Call restore(app)
MockAgent -->> App: Restoration done
App ->> MM: Call restore()
MM -->> App: Restoration done
App -->> User: Return from restore()
Poem
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Run & review this pull request in StackBlitz Codeflow. commit: egg-mock
|
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- index.js (1 hunks)
- lib/mock_agent.js (2 hunks)
Additional comments not posted (3)
lib/mock_agent.js (2)
11-14
: LGTM!The changes ensure that the raw dispatcher is saved if not already set. This is a good addition to ensure the dispatcher is not lost.
25-32
: LGTM!The changes improve the logic for setting the dispatcher, ensuring that the correct dispatcher is restored.
index.js (1)
25-26
: LGTM!The change ensures that
mm.restore
is called after restoring the cluster and mock agent. This sequence is logical and ensures all other restores are completed before calling the final restore.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #170 +/- ##
==========================================
- Coverage 85.51% 85.49% -0.03%
==========================================
Files 27 27
Lines 2623 2619 -4
Branches 472 474 +2
==========================================
- Hits 2243 2239 -4
Misses 380 380 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- lib/mock_agent.js (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- lib/mock_agent.js
There was a problem hiding this 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
[skip ci] ## [5.12.3](v5.12.2...v5.12.3) (2024-07-02) ### Bug Fixes * don't close used mock agent ([#170](#170)) ([3e7a504](3e7a504))
avoid ClientDestroyedError
Summary by CodeRabbit
restore()
method to enhance function execution order.