Skip to content

File import: Zotero attachment paths join base dir with absolute paths; ENOENT stat kills the db-worker (unhandled rejection) #1408

Open
logseq/logseq
#13886

Description

@Svtter

Summary

Two related defects in the file→DB graph importer's Zotero attachment handling. On a graph with Zotero literature notes whose local PDFs no longer exist, the import dies every time at the same point: the db-worker process is killed by an unhandled promise rejection after an asset stat ENOENT, and the renderer hangs with no error surfaced.

Defect 1: base dir joined with absolute paths

get-zotero-local-pdf-path (deps/graph-parser/src/logseq/graph_parser/exporter.cljs:1282) builds <zotero-data-dir>/storage/<id>/<label>, and the {{zotero-linked-file "C:\\...\\foo.pdf"}} macro resolution joins zotero-linked-attachment-base-directory with the absolute path embedded in the macro. With e.g. :zotero/settings-v2 {"default" {:zotero-data-directory "C:\\Users\\me\\Zotero", :zotero-linked-attachment-base-directory "D:\\work\\papers\\zotero-base"}}, the importer stats paths like:

D:\work\papers\zotero-base\C:\Users\me\Documents\Paper\foo.pdf   ← macro variant
C:\Users\me\Zotero\storage\6RVEBFF2\foo.pdf                       ← zotero://select variant

The first form is nonsense on Windows (absolute path appended to another absolute path). The second form points at Zotero storage items that may have been purged. Both should at minimum check isAbsolute and existence, then skip with a warning.

Defect 2: ENOENT stat failure kills the db-worker

<import-file-stat (src/main/frontend/worker/db_core.cljs:330) correctly catches the stat error, logs [severe] :import-file-stat {:fs-path ... :error ENOENT} and returns nil. However something downstream in the asset-resolution chain then throws an unhandled promise rejection (stack ends ... at Object.resolve → hAb in the db-worker-node bundle), which kills the worker process (node exits; db-worker.lock disappears). The renderer never gets an error — the import UI just stops making progress ("loading" forever). In our runs, 30 dead Zotero references killed the import at the same point every time (~41 MB persisted).

Repro

  1. Graph config logseq/config.edn contains :zotero/settings-v2 with a zotero-data-directory (and/or zotero-linked-attachment-base-directory)
  2. Some pages contain [foo.pdf](zotero://select/library/items/KEY) links or {{zotero-linked-file "C:\\...\\foo.pdf"}} macros where the target file/storage item no longer exists
  3. File → Import → File to DB graph → dies deterministically at the first such resolution

Workarounds we used

  • Remove dead {{zotero-linked-file}} macros from the markdown
  • Remove :zotero/settings-v2 from logseq/config.edn before import (get-zotero-local-pdf-path short-circuits on a nil data dir — links survive as regular links)

Environment

Happy to provide the full worker logs (they include the [severe] :import-file-stat chain followed by the uncaught rejection stack) and a minimal markdown repro.

Activity

  1. yuxi-liu-wired commented on Oct 27, 2026

    @yuxi-liu-wired

    Fixed in logseq/logseq#13891 (fix(import): file-graph import keeps tables in quotes and Zotero PDF assets). Its description has the cause and the test that pins it; it fails on current master and passes with the fix.

  2. added 11 commits that reference this issue on Oct 27, 2026
    a0e98a3
    6456664
    93685a6
    10b3451
    9e00e78
    5bafab3
    481621f
    06dce0e
    4175bee
    29c973a
    16a3cca
  3. added 16 commits that reference this issue on Nov 11, 2026
    794fada
    284e1b5
    2439ee3
    8e2bff5
    af3155d
    8ad65e6
    2f3e5d2
    77976d8
    e73949d
    dbdbdbb
    52aa4eb
    ca71249
    15b81b2
    d0ce801
    77f0ffc
    3826546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions