Local Zotero: withZoteroDb closes the DB before an async callback finishes (missing await)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 90/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- sqlite, typescript
调研方向
从 packages/editor-server/src/core/zotero/local/db.ts 中的 withZoteroDbExclusive() 开始,然后检查 source.ts 中第 36、95 和 120 行附近的三个调用方。添加一个使用在查询前执行 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
- 星标
- 652
- 派生
- 64
- 平均合并
- 8 小时 45 分钟
- 30 天内合并 PR
- 36
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/quarto 的其他 Issue
-
VS Code extension: `quarto preview` fails when the file path contains parentheses (path not shell-quoted)可能已有人在做 @Bondrewd-K 于 3 天前认领。 未关闭bug vscode
难度 2/5 1-3 小时 新手友好度 78/100
quarto-dev/quarto#1194 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 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?可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 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 于 51 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 90/100
quarto-dev/quarto#1099 ·
维护者通常 1 天内回复
查看 quarto-dev/quarto 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
Chocobozzz/PeerTube#7832 ·
维护者通常 3 天内回复
-
Pay to use?未关闭
难度 1/5 1 小时以内 新手友好度 66/100
darkreader/darkreader#16108 · 1 条评论 ·
维护者通常 2 天内回复
-
check:passed streams:add
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
bug engine
难度 2/5 1-3 小时 新手友好度 86/100
frostney/GocciaScript#1746 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
agilepathway/label-checker#739 · 4 条评论 ·
维护者通常 1 天内回复