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:
[:find ?e
:in $ ?property
:where
[?e :block/title ?property]]
The worker correctly rejected the request with:
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
- Start
db-worker-node for a non-empty disposable DB graph with error logging enabled.
- Invoke
thread-api/q with a query that declares :in $ ?property, but supply only the query.
- Inspect the graph-local
db-worker-node-YYYYMMDD.log file.
- Observe that the
:db-worker-node-invoke-failed entry contains #datascript/DB, including schema and datoms.
- 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:
(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?
What Happened?
On Logseq Desktop 2.0.1, a malformed
thread-api/qrequest caused the graph-localdb-worker-node-YYYYMMDD.logfile to grow to 3,002,106,416 bytes in about one minute.The query declared two inputs but supplied only the implicit database input:
The worker correctly rejected the request with:
However,
log-invoke-error!logged the complete exception object. DataScript includes the received DB value in the exception's:data :gotfield, so serializing that exception also serialized the graph schema and datoms.Observed impact from one real log:
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
db-worker-nodefor a non-empty disposable DB graph with error logging enabled.thread-api/qwith a query that declares:in $ ?property, but supply only the query.db-worker-node-YYYYMMDD.logfile.:db-worker-node-invoke-failedentry contains#datascript/DB, including schema and datoms.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
db-worker-noderevision reported by the log:b09316aAdditional Context
The relevant path is
src/main/frontend/worker/db_worker_node.cljs:Removing the raw
:errorvalue prevents itsex-datafrom recursively serializing the database. The existingstatus,code,message, andmethodfields preserve the actionable request context. The/v1/import-db-binaryerror 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?