Repository navigation
chore(deps): update dependency nock to v15 - #11055
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning MetaMask internal reviewing guidelines:
|
| headers: Record<string, string>, | ||
| ): nock.Scope { | ||
| return nock(rpcUrl, { reqheaders: headers }).filteringRequestBody((body) => { | ||
| // The types for nock 15 only declare the form of `filteringRequestBody` that |
There was a problem hiding this comment.
nock 15's types only declare filteringRequestBody() with no arguments, but it still accepts a function at runtime, and that form is documented in the README under "Request Body filtering": https://github.com/nock/nock#request-body-filtering
The cast just lets us keep passing the function (it logs each request body through debug), since the typings don't expose that overload anymore.
There was a problem hiding this comment.
I see that the source makes use of arguments as any to accept the function :( https://github.com/nock/nock/blob/415fc645e663aa79d3f9aaa8abbb82f4229ee524/lib/scope.ts#L310. So that must be why. Seems like an acceptable fix to me.
62534f7 to
56f0bd6
Compare
56f0bd6 to
f7c6252
Compare
…ck 15 is the baseline" This reverts commit 7108d47.
f7c6252 to
115ee64
Compare
| headers: Record<string, string>, | ||
| ): nock.Scope { | ||
| return nock(rpcUrl, { reqheaders: headers }).filteringRequestBody((body) => { | ||
| // The types for nock 15 only declare the form of `filteringRequestBody` that |
There was a problem hiding this comment.
I see that the source makes use of arguments as any to accept the function :( https://github.com/nock/nock/blob/415fc645e663aa79d3f9aaa8abbb82f4229ee524/lib/scope.ts#L310. So that must be why. Seems like an acceptable fix to me.
… idiom Main migrated nock to v15 and made the nock-based tests independent of node-fetch (#11077, #11055) by replacing reply-callback request-body assertions with `nock.RequestBodyMatcher` arguments plus `.isDone()` checks. Convert `handleMockSetUserAssets` and its seven call sites to the same idiom — the old callback form hangs under nock v15 with native fetch.
…d transaction controllers (MetaMask#11132) ## Explanation Prepares network-controller, assets-controllers and transaction-controller for the nock 15 upgrade (MetaMask#11055) and removal of the node-fetch shim, so their tests pass on both setups. They share the nock helper in network-controller tests, so this fixes it once, along with timers and fetch error messages in the specs. ## References Related to MetaMask#11055 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Changes are limited to tests and lint suppressions; production code is untouched. > > **Overview** > **Test-only** updates so Nock-based specs stay valid when moving from **node-fetch** to **native `fetch`** and **Nock 15** (related to MetaMask#11055). No production/runtime behavior changes. > > **Network-controller** adds shared helpers: `getNockRequestBody` for Nock reply callbacks that may receive `(uri, body)` or a Fetch `Request`, and `buildFetchErrorPattern` so assertions accept either the original error text or native `fetch`’s generic **"fetch failed"**. RPC retry/circuit tests switch Vitest fake timers to leave `nextTick` / `queueMicrotask` / `setImmediate` real, drive retries with `runOnlyPendingTimersAsync`, and relax a few expectations (Nock mismatch messages, JSON parse errors, request URL from Nock events). `RpcService` tests unwrap `TypeError` causes so Nock errors stay non-retriable like with node-fetch. > > **assets-controllers** and **transaction-controller** mirror the same patterns: regex/`stringMatching` on network errors, timeout tests that hang instead of using long Nock delays, and integration tests that advance timers until promises settle (`advanceUntilSettled`) plus `nock.cleanAll` in teardown. **oxlint-suppressions** drops two entries for `rpc-service.test.ts` after the test fixes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a43379. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…k#11171) ## Explanation On nock 15 only the native fetch error message `fetch failed` occurs, so the either or patterns left from the nock 13 era are dead. This narrows those assertions to the one message that really occurs, keeping `Failed to fetch` where `CodefiTokenPricesServiceV2` throws it itself. ## References Stacked on MetaMask#11055, related to MetaMask#11172 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
MetaMask#11172) ## Explanation Some nock test helpers still handle the nock 13 reply arguments (`(uri, body)`) and error messages, which cannot occur on nock 15. This reduces them to the one nock 15 path (a `Request`), removing `getRequestUrl`, `NockRequestInfo` and `buildFetchErrorPattern`. ## References Stacked on MetaMask#11171 and MetaMask#11055 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only refactors with no production code changes; risk is limited to test suite compatibility with nock 15. > > **Overview** > Test helpers and fixtures are updated to assume **nock 15**, which always passes a Fetch **`Request`** into `.reply()` callbacks and related hooks. > > Shared utilities **`getRequestUrl`**, **`NockRequestInfo`**, and **`buildFetchErrorPattern`** are removed. Interceptors in **assets-controller**, **profile-sync-controller**, and **network-controller** now read query params and bodies via **`request.url`** / **`request.clone()`** instead of branching on URI strings or `(uri, body)` tuples. > > Network-client integration tests stop matching **node-fetch**-style error text and assert the generic **`fetch failed`** message instead, aligned with native **`fetch`** under the current nock stack. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 592521e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…dent of Node.js timing (MetaMask#11186) ## Explanation Since the nock 15 upgrade (MetaMask#11055), `main` fails the concurrent `onDegraded` test in `network-controller` on Node 22 and 24, because both responses are handled in the same turn of the event loop and the shared RPC method name is overwritten. PR checks only run Node 26, which is why it passed there. The test now holds the second response until the first `onDegraded` has fired, which matches how the service attributes the method name and no longer depends on the Node.js version. ## References Related to MetaMask#11055 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only change in `rpc-service.test.ts`; no runtime or RPC service logic modified. > > **Overview** > Fixes a flaky **`RpcService`** test that asserts two concurrent slow RPC calls each fire **`onDegraded`** with the correct **`rpcMethodName`**. > > After the nock 15 upgrade, Node 22/24 could deliver both mocked responses in one event-loop turn, so the service’s shared **`#currentRpcMethodName`** was overwritten before the first callback ran and expectations failed. The test now **gates the second nock reply** on a promise resolved from the **`onDegraded`** mock (first callback unblocks **`eth_gasPrice`**), forcing ordering without relying on Node-specific timing. **Production behavior is unchanged**—test-only. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e954258. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This PR contains the following updates:
^13.5.6→^15.0.5Release Notes
nock/nock (nock)
v15.0.5Compare Source
Bug Fixes
v15.0.4Compare Source
Bug Fixes
v15.0.3Compare Source
Bug Fixes
v15.0.2Compare Source
Bug Fixes
v15.0.1Compare Source
Bug Fixes
v15.0.0Compare Source
Released by accident, please use continue using v14 or v15@beta
v14.0.17Compare Source
Bug Fixes
v14.0.16Compare Source
Bug Fixes
v14.0.15Compare Source
Bug Fixes
v14.0.14Compare Source
Bug Fixes
v14.0.13Compare Source
Bug Fixes
v14.0.12Compare Source
Bug Fixes
v14.0.11Compare Source
Bug Fixes
@mswjs/interceptorsto fix a memory leak (#2938) (025db76)v14.0.10Compare Source
Bug Fixes
v14.0.9Compare Source
Bug Fixes
v14.0.8Compare Source
Bug Fixes
v14.0.7Compare Source
Bug Fixes
v14.0.6Compare Source
Bug Fixes
v14.0.5Compare Source
Bug Fixes
v14.0.4Compare Source
Bug Fixes
v14.0.3Compare Source
Bug Fixes
v14.0.2Compare Source
Bug Fixes
v14.0.1Compare Source
Bug Fixes
v14.0.0Compare Source
BREAKING CHANGES
Features
fetch(#2813) (ef3f158)Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate CLI.
Note
Low Risk
Changes are limited to devDependencies and test setup; production packages are unaffected aside from lockfile churn.
Overview
Upgrades nock from
^13.5.6to^15.0.5across the root and all packages that mock HTTP in tests. Nock 15 intercepts nativefetch(via@mswjs/interceptors), so the monorepo drops the rootnode-fetchdevDependency and deletestests/vitest/setup.ts, which previously patchedglobalThis.fetchfor nock. Package Vitest config now only loadssetup-after-env.ts.A few tests and fixtures were adjusted for nock 15 behavior and typings: network failures may surface as
fetch failedinstead of the mocked error string;network-controllertest helpers use a type cast sofilteringRequestBodywith a callback still type-checks; minor mock/type tweaks in assets and profile-sync fixtures.tsc-suppressions.jsondrops obsolete nock-related suppressions where types now align.Reviewed by Cursor Bugbot for commit 115ee64. Bugbot is set up for automated code reviews on this repo. Configure here.