Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion jest.config.packages.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ module.exports = {
// CommonJS, where the reverse is true, so they are pointed back at
// `lodash`. The two have the same API.
'^lodash-es$': require.resolve('lodash'),
// `cockatiel` is ESM only, and the tests compile to CommonJS, where it can
// only be `require`d on Node 24.9+. This shim hands out the namespace that
// `tests/setupCockatiel.mjs` loads through Jest's ESM loader instead, which
// also works on Node 22.
'^cockatiel$': '<rootDir>/../../tests/cockatiel.cjs',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
Expand Down Expand Up @@ -149,7 +154,10 @@ module.exports = {
setupFiles: ['../../tests/setup.ts'],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ['../../tests/setupAfterEnv/index.ts'],
setupFilesAfterEnv: [
'../../tests/setupCockatiel.mjs',
'../../tests/setupAfterEnv/index.ts',
],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
Expand Down
5 changes: 5 additions & 0 deletions oxlint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7440,6 +7440,11 @@
"count": 2
}
},
"tests/cockatiel.cjs": {
"import/unambiguous": {
"count": 1
}
},
"tests/helpers.ts": {
"id-length": {
"count": 1
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@yarnpkg/parsers": "^3.0.3",
"@yarnpkg/types": "^4.0.0",
"bats": "^1.13.0",
"cockatiel": "^4.0.0",
"comment-json": "^4.5.1",
"eslint-plugin-n": "^18.3.0",
"execa": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/base-data-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `@metamask/utils` from `^11.12.0` to `^12.0.0` ([#10192](https://github.com/MetaMask/core/pull/10192))
- Add `uuid` `^11.1.1` as a dependency ([#9324](https://github.com/MetaMask/core/pull/9324))
- Bump `@tanstack/query-core` from `^5.62.16` to `^5.89.0` ([#9324](https://github.com/MetaMask/core/pull/9324))
- Bump `cockatiel` from `^3.1.2` to `^3.2.1` ([#10436](https://github.com/MetaMask/core/pull/10436))
- Bump `cockatiel` from `^3.1.2` to `^4.0.0` ([#10436](https://github.com/MetaMask/core/pull/10436), [#10381](https://github.com/MetaMask/core/pull/10381))
- Bump `lodash-es` from `^4.17.21` to `^4.18.1` ([#10447](https://github.com/MetaMask/core/pull/10447))

## [2.0.0]
Expand Down
2 changes: 1 addition & 1 deletion packages/base-data-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@metamask/superstruct": "^3.4.1",
"@metamask/utils": "^12.0.0",
"@tanstack/query-core": "^5.89.0",
"cockatiel": "^3.2.1",
"cockatiel": "^4.0.0",
"fast-deep-equal": "^3.1.3",
"lodash-es": "^4.18.1",
"uuid": "^11.1.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `@metamask/utils` from `^11.12.0` to `^12.0.0` ([#10192](https://github.com/MetaMask/core/pull/10192))
- Bump `@types/bn.js` from `^5.1.5` to `^5.2.0` ([#10362](https://github.com/MetaMask/core/pull/10362))
- Bump `bn.js` from `^5.2.1` to `^5.2.5` ([#10362](https://github.com/MetaMask/core/pull/10362))
- Bump `cockatiel` from `^3.1.2` to `^3.2.1` ([#10436](https://github.com/MetaMask/core/pull/10436))
- Bump `cockatiel` from `^3.1.2` to `^4.0.0` ([#10436](https://github.com/MetaMask/core/pull/10436), [#10381](https://github.com/MetaMask/core/pull/10381))
- Bump `lodash-es` from `^4.17.21` to `^4.18.1` ([#10447](https://github.com/MetaMask/core/pull/10447))

## [13.0.0]
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@types/bn.js": "^5.2.0",
"bignumber.js": "^9.1.2",
"bn.js": "^5.2.5",
"cockatiel": "^3.2.1",
"cockatiel": "^4.0.0",
"eth-ens-namehash": "^2.0.8",
"fast-deep-equal": "^3.1.3",
"lodash-es": "^4.18.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/core-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `@metamask/profile-sync-controller` from `^32.1.1` to `^33.0.0` ([#10348](https://github.com/MetaMask/core/pull/10348), [#10409](https://github.com/MetaMask/core/pull/10409), [#10418](https://github.com/MetaMask/core/pull/10418), [#10459](https://github.com/MetaMask/core/pull/10459))
- Bump `@tanstack/query-core` from `^5.62.16` to `^5.89.0` ([#9324](https://github.com/MetaMask/core/pull/9324))
- Bump `@metamask/keyring-controller` from `^28.0.0` to `^28.1.0` ([#10418](https://github.com/MetaMask/core/pull/10418))
- Bump `cockatiel` from `^3.1.2` to `^3.2.1` ([#10436](https://github.com/MetaMask/core/pull/10436))
- Bump `cockatiel` from `^3.1.2` to `^4.0.0` ([#10436](https://github.com/MetaMask/core/pull/10436), [#10381](https://github.com/MetaMask/core/pull/10381))
- Bump `@metamask/account-tree-controller` from `^10.0.1` to `^11.0.0` ([#10459](https://github.com/MetaMask/core/pull/10459))

## [11.0.0]
Expand Down
2 changes: 1 addition & 1 deletion packages/core-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@metamask/utils": "^12.0.0",
"@tanstack/query-core": "^5.89.0",
"async-mutex": "^0.5.0",
"cockatiel": "^3.2.1",
"cockatiel": "^4.0.0",
"uuid": "^11.1.1"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `@metamask/utils` from `^11.12.0` to `^12.0.0` ([#10192](https://github.com/MetaMask/core/pull/10192))
- Bump `immer` from `^9.0.6` to `^11.1.18` ([#10331](https://github.com/MetaMask/core/pull/10331), [#10382](https://github.com/MetaMask/core/pull/10382))
- Bump `@metamask/analytics-controller` from `^3.0.0` to `^3.2.0` ([#10301](https://github.com/MetaMask/core/pull/10301), [#10411](https://github.com/MetaMask/core/pull/10411))
- Bump `cockatiel` from `^3.1.2` to `^4.0.0` ([#10436](https://github.com/MetaMask/core/pull/10436), [#10381](https://github.com/MetaMask/core/pull/10381))

## [37.0.0]

Expand Down
2 changes: 1 addition & 1 deletion packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@types/lodash-es": "^4.17.12",
"@types/node-fetch": "^2.6.12",
"@typescript/native": "npm:typescript@^7.0.2",
"cockatiel": "^3.2.1",
"cockatiel": "^4.0.0",
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.3.1",
"jest": "^30.4.2",
Expand Down
24 changes: 17 additions & 7 deletions packages/network-controller/src/rpc-service/rpc-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {
handleWhen,
} from '@metamask/controller-utils';
import { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';
import { Duration, getErrorMessage, hasProperty } from '@metamask/utils';
import {
Duration,
getErrorMessage,
hasProperty,
isObject,
} from '@metamask/utils';
import type {
Json,
JsonRpcParams,
Expand Down Expand Up @@ -231,9 +236,10 @@ export function isJsonParseError(error: unknown): boolean {
* @param error - The error object to test.
* @returns True if the error has an httpStatus of 502, 503, or 504.
*/
export function isHttpServerError(error: Error): boolean {
export function isHttpServerError(error: unknown): boolean {
return (
'httpStatus' in error &&
isObject(error) &&
hasProperty(error, 'httpStatus') &&
(error.httpStatus === 502 ||
error.httpStatus === 503 ||
error.httpStatus === 504)
Expand All @@ -246,8 +252,10 @@ export function isHttpServerError(error: Error): boolean {
* @param error - The error object to test.
* @returns True if the error code is `ETIMEDOUT`.
*/
export function isTimeoutError(error: Error): boolean {
return hasProperty(error, 'code') && error.code === 'ETIMEDOUT';
export function isTimeoutError(error: unknown): boolean {
return (
isObject(error) && hasProperty(error, 'code') && error.code === 'ETIMEDOUT'
);
}

/**
Expand All @@ -256,8 +264,10 @@ export function isTimeoutError(error: Error): boolean {
* @param error - The error object to test.
* @returns True if the error code is `ECONNRESET`.
*/
export function isConnectionResetError(error: Error): boolean {
return hasProperty(error, 'code') && error.code === 'ECONNRESET';
export function isConnectionResetError(error: unknown): boolean {
return (
isObject(error) && hasProperty(error, 'code') && error.code === 'ECONNRESET'
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/shield-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bump `@metamask/transaction-controller` from `^72.0.0` to `^72.0.1` ([#10462](https://github.com/MetaMask/core/pull/10462))
- Bump `cockatiel` from `^3.2.1` to `^4.0.0` ([#10381](https://github.com/MetaMask/core/pull/10381))

## [7.0.3]

Expand Down
2 changes: 1 addition & 1 deletion packages/shield-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@metamask/transaction-controller": "^72.0.1",
"@metamask/utils": "^12.0.0",
"@tanstack/query-core": "^5.89.0",
"cockatiel": "^3.2.1"
"cockatiel": "^4.0.0"
},
"devDependencies": {
"@babel/runtime": "^7.23.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/shield-controller/src/polling-with-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class PollingWithCockatielPolicy {
this.#requestEntry.delete(requestId);
}

#shouldRetry(error: Error): boolean {
#shouldRetry(error: unknown): boolean {
if (error instanceof HttpError) {
// Note: we don't retry on 5xx errors, only on 4xx errors.
// but we won't retry on 400 coz it means that the request body is invalid.
Expand Down
2 changes: 2 additions & 0 deletions tests/cockatiel.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See `tests/setupCockatiel.mjs`, which puts the namespace here.
module.exports = globalThis.__cockatiel__;
17 changes: 17 additions & 0 deletions tests/setupCockatiel.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// `cockatiel` is published as ESM only, and the package tests run as CommonJS.
// Jest can only `require()` an ES module on Node 24.9+, where the synchronous
// vm module APIs exist, so on Node 22 a plain `import` from a test file fails.
//
// Loading it here instead works on both, because this file is ESM and Jest
// loads it through its asynchronous ESM loader (enabled by
// `--experimental-vm-modules`). It stays inside the test sandbox, so fake
// timers and `instanceof` behave as they would for any other module.
//
// `tests/cockatiel.cjs` hands this namespace to anything that imports
// `cockatiel`; see the `moduleNameMapper` entry in `jest.config.packages.cjs`.
//
// The import below deliberately points at the real entry point rather than at
// `cockatiel`, which `moduleNameMapper` would send straight back here.
import * as cockatiel from 'cockatiel/dist/index.js';

globalThis.__cockatiel__ = cockatiel;
20 changes: 14 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5953,7 +5953,7 @@ __metadata:
"@types/jest": "npm:^30.0.0"
"@types/lodash-es": "npm:^4.17.12"
"@typescript/native": "npm:typescript@^7.0.2"
cockatiel: "npm:^3.2.1"
cockatiel: "npm:^4.0.0"
deepmerge: "npm:^4.3.1"
fast-deep-equal: "npm:^3.1.3"
jest: "npm:^30.4.2"
Expand Down Expand Up @@ -6393,7 +6393,7 @@ __metadata:
"@typescript/native": "npm:typescript@^7.0.2"
bignumber.js: "npm:^9.1.2"
bn.js: "npm:^5.2.5"
cockatiel: "npm:^3.2.1"
cockatiel: "npm:^4.0.0"
deepmerge: "npm:^4.3.1"
eth-ens-namehash: "npm:^2.0.8"
fast-deep-equal: "npm:^3.1.3"
Expand Down Expand Up @@ -6428,7 +6428,7 @@ __metadata:
"@types/jest": "npm:^30.0.0"
"@typescript/native": "npm:typescript@^7.0.2"
async-mutex: "npm:^0.5.0"
cockatiel: "npm:^3.2.1"
cockatiel: "npm:^4.0.0"
deepmerge: "npm:^4.3.1"
jest: "npm:^30.4.2"
jest-environment-jsdom: "npm:^30.4.1"
Expand Down Expand Up @@ -6472,6 +6472,7 @@ __metadata:
"@yarnpkg/parsers": "npm:^3.0.3"
"@yarnpkg/types": "npm:^4.0.0"
bats: "npm:^1.13.0"
cockatiel: "npm:^4.0.0"
comment-json: "npm:^4.5.1"
eslint-plugin-n: "npm:^18.3.0"
execa: "npm:^10.0.1"
Expand Down Expand Up @@ -7925,7 +7926,7 @@ __metadata:
"@types/lodash-es": "npm:^4.17.12"
"@types/node-fetch": "npm:^2.6.12"
"@typescript/native": "npm:typescript@^7.0.2"
cockatiel: "npm:^3.2.1"
cockatiel: "npm:^4.0.0"
deep-freeze-strict: "npm:^1.1.1"
deepmerge: "npm:^4.3.1"
fast-deep-equal: "npm:^3.1.3"
Expand Down Expand Up @@ -8771,7 +8772,7 @@ __metadata:
"@tanstack/query-core": "npm:^5.89.0"
"@types/jest": "npm:^30.0.0"
"@typescript/native": "npm:typescript@^7.0.2"
cockatiel: "npm:^3.2.1"
cockatiel: "npm:^4.0.0"
deepmerge: "npm:^4.3.1"
jest: "npm:^30.4.2"
lodash-es: "npm:^4.18.1"
Expand Down Expand Up @@ -15265,13 +15266,20 @@ __metadata:
languageName: node
linkType: hard

"cockatiel@npm:^3.1.2, cockatiel@npm:^3.2.1":
"cockatiel@npm:^3.1.2":
version: 3.2.1
resolution: "cockatiel@npm:3.2.1"
checksum: 10/b022d588dc1e31db59a17527b89acd6ed52c6d8761402afe112c7688af8836363e260ebf71b6f07c7edd69e62047adbf9fc1b3ffcb9081b7a0a751e6018773a6
languageName: node
linkType: hard

"cockatiel@npm:^4.0.0":
version: 4.0.0
resolution: "cockatiel@npm:4.0.0"
checksum: 10/443bc255c19e2fb318296aff1a45c0db3c461d62f88ad4acb33db22db8880844eeab0c30c2e653d4efc5f7f0b3c2eec105514896d14c0aaa8f78dd33c790f2f9
languageName: node
linkType: hard

"code-block-writer@npm:^13.0.3":
version: 13.0.3
resolution: "code-block-writer@npm:13.0.3"
Expand Down
Loading