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

Local Zotero: withZoteroDb closes the DB before an async callback finishes (missing await)

オープン 初心者向け
#1,138 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
sqlite, typescript
領域
backend, databases

調査の方向性

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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

quarto-dev/quarto のほかの issue

quarto-dev/quarto の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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