db-worker-node logs the full DataScript DB for query input errors, producing multi-gigabyte log files
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 28
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
## What Happened?
On Logseq Desktop 2.0.1, a malformed `thread-api/q` request caused the graph-local `db-worker-node-YYYYMMDD.log` file to grow to 3,002,106,416 bytes in about one minute.
The query declared two inputs but supplied only the implicit database input:
```clojure
[:find ?e
:in $ ?property
:where
[?e :block/title ?property]]
```
The worker correctly rejected the request with:
```text
Too few inputs passed, expected: [$ ?property], got: 1
```
However, `log-invoke-error!` logged the complete exception object. DataScript includes the received DB value in the exception's `:data :got` field, so serializing that exception also serialized the graph schema and datoms.
Observed impact from one real log:
- Total file size: 3,002,106,416 bytes (2.8 GiB)
- Total lines: 894
- Oversized lines: 75
- Size of each oversized line: 40,024,609 bytes
- Total size of oversized lines: 3,001,845,675 bytes
- Time window: 2026-08-12T15:43:03.086Z to 2026-08-12T15:44:10.047Z
This is also a privacy concern because the log contains graph titles and datoms. I am therefore not attaching the original log.
The invalid query was issued repeatedly by a caller, which is a separate caller bug. Regardless of the caller, one rejected worker request should not write an entire graph to disk.
## Reproduce the Bug
1. Start `db-worker-node` for a non-empty disposable DB graph with error logging enabled.
2. Invoke `thread-api/q` with a query that declares `:in $ ?property`, but supply only the query.
3. Inspect the graph-local `db-worker-node-YYYYMMDD.log` file.
4. Observe that the `:db-worker-node-invoke-failed` entry contains `#datascript/DB`, including schema and datoms.
5. Repeat the request and observe that the log grows by roughly the serialized size of the graph each time.
## Expected Behavior
The worker should retain useful diagnostics such as status, error code, message, and method, but it should not serialize the DataScript DB or graph contents into the log.
## Desktop or Mobile Platform Information
- macOS Desktop
- Logseq 2.0.1
- `db-worker-node` revision reported by the log: `b09316a`
- DB graph
## Additional Context
The relevant path is `src/main/frontend/worker/db_worker_node.cljs`:
```clojure
(log/error :db-worker-node-invoke-failed
{:status status
:code code
:error error
:message message
:method method-kw})
```
Removing the raw `:error` value prevents its `ex-data` from recursively serializing the database. The existing `status`, `code`, `message`, and `method` fields preserve the actionable request context. The `/v1/import-db-binary` error path contains the same raw-error logging and can use the shared sanitized helper as well.
The original caller could not be identified from the worker log, but the worker-side behavior is deterministic and reproducible in a disposable graph without the original caller or graph.
## Are you willing to submit a PR?
- [x] I'm willing to submit a PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/main/frontend/worker/db_worker_node.cljs at the :db-worker-node-invoke-failed logging call and inspect the /v1/import-db-binary error path for the same raw-error logging. Reproduce the malformed thread-api/q request against a disposable non-empty graph, then verify that logs retain status, code, message, and method without serializing the DataScript DB or graph contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100