Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

forEach should await the iteratorCallback

オープン
#154 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript
領域
databases

調査の方向性

storage forEach の実装から開始し、iteratorCallback をどのように呼び出しているかを追跡します。返される Promise が async な remove 呼び出しの完了を待機することを確認し、その後の save が clear と競合しないようにします。payload には特定のファイルやテストは指定されていません。

索引モデルが issue の本文から書いたものです。

説明

We have a situation where we want to clear a bunch of items from storage, and then set items immediately after. We need to await the clear step before saving to prevent the clear from clearing the newly added items.

We are using forEach to iterate through storage, check each item and remove it if need be. Since remove is async we are awaiting it in the iteratorCallback and our iteratorCallback is marked as async. From the source code for storage we can see that the iteratorCallback is not awaited. This means that the forEach Promise could resolve before all the removes have completed.

Here is a sample of what our clear function is doing:

async clear() {
        await this.storage.forEach(async (v, k, i) => {
            if (k.startsWith(this.barcodeStorageKey) || k.startsWith(this.principleStorageKey)) {
                await this.storage.remove(k);
            }
        });
    }

We are using "@ionic/storage": "2.1.3"

主要言語
TypeScript
スター
456
フォーク
97
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ionic-team/ionic-storage のほかの issue

ionic-team/ionic-storage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。