Local Zotero: withZoteroDb closes the DB before an async callback finishes (missing await)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 90/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- sqlite, typescript
調査の方向性
packages/editor-server/src/core/zotero/local/db.ts の withZoteroDbExclusive() から始め、次に source.ts の 36、95、120 行付近にある 3 つの呼び出し元を確認します。クエリを実行する前に await する callback を使った回帰テストを追加し、関連する editor-server のテストを実行します。完了の条件は、非同期 callback が完了するまでデータベースが利用可能なままとなり、その後に閉じられることです。
索引モデルが issue の本文から書いたものです。
説明
Bug (latent)
withZoteroDbExclusive() in packages/editor-server/src/core/zotero/local/db.ts:74 does:
try {
db = new Database(...);
...
return f(db); // f: (db) => Promise<T>
} finally {
if (db) db.close(); // runs as soon as f returns its promise
...
}
Because f(db) is returned without await, the finally runs as soon as f hands back its promise, not when that promise settles. If f ever awaits anything before it finishes using db, the database is closed out from under it, and the next db.all(...) throws.
Current status
It doesn't bite today. The node-sqlite3-wasm API is synchronous, and all three callers in source.ts (lines ~36, ~95, ~120) are async callbacks that never await, so their DB work finishes synchronously before the promise is returned. The trap is that anyone who adds an await inside one of those callbacks (a network call to the Zotero web API, a file read, etc.) breaks it, and the resulting "database closed" error will be confusing.
Fix
return await f(db);
That's the whole change. withZoteroDbExclusive is already async, so this just moves close() until after f settles. Consider adding a unit test with a callback that awaits (e.g. await Promise.resolve()) before querying.
Found during the dependency-upgrade research.
- 主要言語
- TypeScript
- スター
- 655
- フォーク
- 64
- 平均マージ
- 22時間 16分
- マージ済み PR(30日)
- 42
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quarto-dev/quarto のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
quarto-dev/quarto#1139 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
quarto-dev/quarto#1137 ·
メンテナーはふだん 1 日以内に返信
-
Add dependabot?再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
quarto-dev/quarto#1135 ·
メンテナーはふだん 1 日以内に返信
-
AceNodeView: programmatic setSelection() marks the cursor dirty, scrolling the document to the front matter対応中かも @kevinushey が 55 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
quarto-dev/quarto#1099 ·
メンテナーはふだん 1 日以内に返信
-
vscode
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
quarto-dev/quarto#934 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
quarto-dev/quarto の issue をすべて見る
似ている issue
-
area: repo priority: P2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
appandflow/stim#4107 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1〜3時間 初心者へのやさしさ 60/100
lingdojo/kana-dojo#32859 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
code-quality refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/gh-aw-firewall#10364 ·
メンテナーはふだん 1 日以内に返信
-
Merge the duplicate kaffir_corn record into sorghum対応中かも @Crypto-Shroom が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Crypto-Shroom/Bird-Feed-Calculator#322 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
drizzle-team/drizzle-orm#6552 ·
メンテナーはふだん 2 日以内に返信