Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#1,138 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
90/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
sqlite, typescript
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu trong packages/editor-server/src/core/zotero/local/db.ts tại withZoteroDbExclusive(), sau đó xem lại ba bên gọi trong source.ts quanh các dòng 36, 95 và 120. Thêm một regression test bằng cách sử dụng một callback thực hiện await trước khi truy vấn, và chạy các test editor-server liên quan; hoàn tất khi cơ sở dữ liệu vẫn có thể sử dụng được cho đến khi callback bất đồng bộ hoàn tất rồi mới đóng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
655
Fork
64
Merge trung bình
22 giờ 16 phút
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/quarto

Tất cả issue của quarto-dev/quarto

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.