-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: port the Http Provider to v3 #5580
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
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.
Testing the merge queue, please ignore this review
- Created a Dispatcher type alias for UndiciT.Dispatcher. - This change ensures that Undici types are not directly exposed in getDispatcher. - In the future, we may narrow down the Dispatcher type to include only the required properties.
- Copied the getHardhatVersion helper from the hardhat package to the core package. - Added a caching mechanism to store the hardhat version once obtained, improving performance. - The future structure of the packages is still uncertain: we might have two different packages each with its own version, different packages with mirrored versions, or a single combined package for core and hardhat. - Currently, the helper is duplicated, which may be sufficient for now but might need to be revisited in the future.
- Added ConnectionRefusedError handling for ECONNREFUSED errors. - Added RequestTimeoutError handling for UND_ERR_CONNECT_TIMEOUT, UND_ERR_HEADERS_TIMEOUT, and UND_ERR_BODY_TIMEOUT errors.
…tDispatcher - Added getTestDispatcher function to obtain a MockAgent from undici. - Refactored test code to use a new helper function initializeTestDispatcher, which sets up the test dispatcher and returns an interceptor. - Renamed mockPool to interceptor in the test file for clarity.
- Introduced a new error type ResponseStatusCodeError to handle 4xx and 5xx HTTP response status codes. This is needed because we set throwOnError to true in all requests. - ResponseStatusCodeError includes `statusCode`, `headers`, and `body` properties.
- Ported existing HTTP provider functionality to v-next. - Updated code to support ESM, follow modern TypeScript practices, and use hardhat-utils. - Added tests for request and sendBatch.
… tests - Moved error handling logic to a handleError function to avoid code duplication. - Updated the error handling to correctly check for e.cause.code or e.code existence. - Fixed tests that were not previously updated to expect ResponseStatusCodeError.
- Added send and sendAsync from the backwards compatibility provider as we're no longer going to use wrappers. - Added jsdoc for the public methods. - Changed the HttpProvider.create signature to receive a config object. timeout is no longer optional in this object. - Default the params to an empty array if not provided. - Renamed delay to sleep. - Do not set error.data on failed retry.
0091a89
to
7229bd0
Compare
Part of #5549
The PR includes all the changes required for porting the
HttpProvider
and tests for therequest
andsendBatch
methods. The PR is quite large, but it can be reviewed commit by commit. Each commit includes a description of the changes made.