-
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: should reset agent on restore #171
Conversation
WalkthroughThe recent changes focus on converting several functions from synchronous to asynchronous by adding the Changes
Poem
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 (6)
- app/extend/agent.js (1 hunks)
- app/extend/application.js (1 hunks)
- index.js (1 hunks)
- lib/app.js (1 hunks)
- lib/mock_agent.js (3 hunks)
- test/mock_httpclient_next_h2.test.js (1 hunks)
Files skipped from review due to trivial changes (1)
- lib/app.js
Additional comments not posted (8)
app/extend/agent.js (1)
28-29
: ConvertmockAgentRestore
to an async function.The function
mockAgentRestore
has been correctly converted to an asynchronous function usingawait
formockAgent.restore()
. This ensures that any asynchronous operations withinrestore
are properly handled.lib/mock_agent.js (3)
1-5
: Add debug logging and httpClients array.The
debuglog
fromutil
is correctly imported and initialized. ThehttpClients
array is introduced to manage multiplehttpclient
instances. This setup looks good for enhancing debugging and managing multiple instances.
Line range hint
9-20
:
Add httpClient to the httpClients array.The code correctly adds
httpclient
to thehttpClients
array and logs the size of the array. This ensures that all httpClients are tracked and can be restored later.
31-42
: Convertrestore
to an async function and handle multiple httpClients.The
restore
function is correctly converted to an asynchronous function. It handles restoring the global dispatcher, resetting eachhttpClient
to its original dispatcher, and closing the_mockAgent
asynchronously. This ensures proper cleanup of resources.index.js (1)
23-26
: Convertrestore
to an async function.The
restore
function is correctly converted to an asynchronous function usingawait
forcluster.restore()
,mockAgent.restore()
, andmm.restore()
. This ensures that all asynchronous operations are properly handled.app/extend/application.js (1)
309-310
: ConvertmockAgentRestore
to an async function.The function
mockAgentRestore
has been correctly converted to an asynchronous function usingawait
formockAgent.restore()
. This ensures that any asynchronous operations withinrestore
are properly handled.test/mock_httpclient_next_h2.test.js (2)
195-204
: LGTM!The test case ensures that the application restores the state after each test case.
Line range hint
205-224
:
LGTM!The test case ensures that the first mock data is used when there are duplicate URL mocks.
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)
- test/app.test.js (1 hunks)
Additional comments not posted (1)
test/app.test.js (1)
256-256
: LGTM!The addition of
await
beforemm.restore()
aligns with the PR objective of converting functions to asynchronous operations.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #171 +/- ##
==========================================
+ Coverage 85.49% 85.53% +0.04%
==========================================
Files 27 27
Lines 2619 2627 +8
Branches 474 474
==========================================
+ Hits 2239 2247 +8
Misses 380 380 ☔ View full report in Codecov by Sentry. |
[skip ci] ## [5.12.4](v5.12.3...v5.12.4) (2024-07-04) ### Bug Fixes * should reset agent on restore ([#171](#171)) ([088ac41](088ac41))
Summary by CodeRabbit
New Features
Bug Fixes
lib/app.js
.Refactor
mockAgentRestore
andrestore
functions to use async/await for better handling of asynchronous operations.httpclient
instances with debug logging.