Skip to content

Replace await-semaphore with async-mutex - #334

Merged
Gudahtt merged 1 commit into
developfrom
replace-await-semaphore
Feb 5, 2021
Merged

Gudahtt merged 1 commit into
developfrom
replace-await-semaphore

Conversation

@Gudahtt

@Gudahtt Gudahtt commented Feb 2, 2021

Copy link
Copy Markdown
Member

We've had issues with await-semaphore causing TypeScript errors due to mistakes in how it is packaged. It generally seems to be abandoned.

async-mutex is more actively maintained, has better documentation and test coverage, and is API-compatible for our usage.

@Gudahtt

Gudahtt commented Feb 2, 2021 •

Copy link
Copy Markdown
Member Author

I'll leave this in draft until MetaMask/eth-json-rpc-filters#33 is merged and published. Until we purge this package from our dependency tree entirely, the same TypeScript error we ran into might crop up again.

Edit: This now depends upon #336

@Gudahtt
Gudahtt force-pushed the replace-await-semaphore branch from 55a14c9 to 0ec62ea Compare February 5, 2021 17:43
@Gudahtt
Gudahtt changed the base branch from develop to update-eth-json-rpc-filters-lockfile February 5, 2021 17:43
Base automatically changed from update-eth-json-rpc-filters-lockfile to develop February 5, 2021 18:52
@Gudahtt
Gudahtt force-pushed the replace-await-semaphore branch from 0ec62ea to edc5299 Compare February 5, 2021 18:53
We've had issues with `await-semaphore` causing TypeScript errors due
to mistakes in how it is packaged. It generally seems to be abandoned.

`async-mutex` is more actively maintained, has better documentation and
test coverage, and is API-compatible for our usage.
@Gudahtt
Gudahtt force-pushed the replace-await-semaphore branch from edc5299 to 40c9e38 Compare February 5, 2021 18:55
@Gudahtt
Gudahtt marked this pull request as ready for review February 5, 2021 18:55
@Gudahtt
Gudahtt requested a review from a team as a code owner February 5, 2021 18:55
@Gudahtt
Gudahtt merged commit 49d3b0b into develop Feb 5, 2021
@Gudahtt
Gudahtt deleted the replace-await-semaphore branch February 5, 2021 20:05
rickycodes added a commit that referenced this pull request Feb 18, 2021
…ba into feature/migrate-to-etherscan

* 'feature/migrate-to-etherscan' of github.com:MetaMask/gaba:
  Update `sinon` and `@types/sinon` to latest versions (#352)
  Fix `tsconfig.json` indentation (#355)
  Replace `fetch-mock` with `nock` (#340)
  Update `ethereumjs-wallet` from v0.6.5 to v1.0.1 (#347)
  Add `babel-runtime` dependency required by `ethjs-query` (#341)
  Update `@metamask/eslint-config` from v3 to v4.1.0 (#344)
  Add `docs` to list of ignored eslint patterns (#345)
  Update `uuid` from `v3.3.3` to `v8.3.2` (#346)
  Update approval controller test import (#339)
  Add Dependabot config (#343)
  Update `typedoc` (#342)
  Remove unused test module (#338)
  Replace `await-semaphore` with `async-mutex` (#334)
  Update `eth-json-rpc-filters` in lockfile (#336)
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
Update the package `@metamask/eth-json-rpc-provider` from v4 to v5. The
breaking change in this release was to remove the `data` event from the
provider, which is not used by this package.

Changelog:
https://github.com/MetaMask/core/blob/main/packages/eth-json-rpc-provider/CHANGELOG.md#500
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
amitabh94 pushed a commit to amitabh94/core that referenced this pull request Jun 16, 2026
* 10.0.1

* Update CHANGELOG.md

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Daniel <80175477+dan437@users.noreply.github.com>
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Sep 13, 2026
Top of stack MetaMask#331, on MetaMask#333. Opts this package into the progressive test
type checking rollout core is doing (16 of its 100 packages so far).

## Tests were not type checked at all

Verified by injecting `const deliberateTypeError: number = "a string"`
into a test file:

| Check | Result |
| --- | --- |
| `yarn build` | passes, `tsconfig.build.json` excludes tests |
| `yarn test:source` | passes, see below |
| `yarn test:types` | passes, tsd only reads `*.test-d.ts` |
| `yarn lint` | passes |

`test:source` can never catch it: `isolatedModules` puts ts-jest on its
`transpileModule` path, which erases types without checking them.

## The change

```
lint:tsc = tsc --noEmit --project tsconfig.lint.json     ← added to `lint`
```

`tsconfig.lint.json` extends `tsconfig.json` (which already covers
everything the build does not) and adds `skipLibCheck`, because
dependency declarations do not satisfy the strict flags used here.

## Why `*.test-d.ts` is excluded

Those belong to `tsd`, which checks them itself via `yarn test:types`
(fixed in MetaMask#322). Including them here pulls `tsd`'s own types into the
program, and those reach `type-fest`, whose `basic.d.ts` carries `///
<reference lib="esnext" />`. That silently widens built in types past
this package's `lib`, producing a spurious failure where `FrozenSet` no
longer satisfies `ReadonlySet` because of Set methods we do not target.
Traced with `tsc --explainFiles`.

## Why this stacks on ES2022

With `lib: ES2020` a `tsc` pass over the tests reports **11 errors**,
nearly all `Property 'cause' does not exist`. With `lib: ES2022`,
**zero**. MetaMask#333 has to land first.

## Confirmed not vacuous

A deliberate type error in a test file now exits non-zero with `TS2322`,
and `tsd` still independently catches a bad `expectAssignable` in a
`.test-d.ts` file.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Dev-only lint and TypeScript config changes; no runtime or shipped
library behavior changes.
> 
> **Overview**
> **`yarn lint` now runs TypeScript on test and other non-build code**
through a new `lint:tsc` script, closing a gap where
`tsconfig.build.json` and transpile-only Jest never validated types in
`*.test.ts` files.
> 
> A new **`tsconfig.lint.json`** extends the root config with
`skipLibCheck`, incremental **`emitDeclarationOnly`** output under
**`.tsc-lint-cache/`** (gitignored and ignored by ESLint), and an
**exclude** for **`*.test-d.ts`** so `tsd`-owned type tests are not
double-checked or polluted by `tsd`’s wider `lib` types.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
670fa8aa1187a15a6935a75ea693271e6e4e1fb5. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants