can1357/oh-my-pi · error · TypeError
DeltaSync requires a memory object with conn or db
Error message
DeltaSync requires a memory object with conn or db
What it means
DeltaSync needs a SQLite connection to read/write sync state, and it obtains one from the memory host object's conn or db property. If the host object passed to the DeltaSync constructor has neither (or they are undefined), databaseOf throws this TypeError so sync is never attempted against a missing database.
Source
Thrown at packages/mnemopi/src/core/streaming.ts:283
};
}
toJson(): string {
return JSON.stringify(this.toDict());
}
static fromJSON(text: string): SyncCheckpoint {
return new SyncCheckpoint(JSON.parse(text) as SyncCheckpointInit);
}
}
type MemoryHost = {
readonly conn?: Database;
readonly db?: Database;
readonly dbPath?: string;
readonly db_path?: string;
};
function databaseOf(host: MemoryHost): Database {
const db = host.conn ?? host.db;
if (db === undefined) throw new TypeError("DeltaSync requires a memory object with conn or db");
return db;
}
function assertDeltaTable(table: unknown): asserts table is DeltaTable {
if (typeof table !== "string" || !ALLOWED_DELTA_TABLES.has(table as DeltaTable))
throw new RangeError(`Delta table ${String(table)} is not in the allowlist`);
}
function checkpointRoot(host: MemoryHost): string {
const path = host.dbPath ?? host.db_path;
return path === undefined || path === ":memory:"
? join(process.cwd(), ".mnemopi-sync")
: join(path, "..", "sync_checkpoints");
}
export class DeltaSync {
readonly checkpointDir: string;
private readonly db: Database;
constructor(
readonly mnemopi: MemoryHost,View on GitHub (pinned to 9690622007)
Solutions
- Ensure the object passed to DeltaSync has an open Database on conn or db (e.g. memory.conn = new Database(path))
- Pass the actual memory host instance, not a plain/config object
- Open the database before constructing DeltaSync and keep the reference alive
Example fix
// before
const sync = new DeltaSync({ id: "m1" });
// after
const memory = { id: "m1", conn: new Database("./memories.db") };
const sync = new DeltaSync(memory); Defensive patterns
Strategy: type-guard
Validate before calling
function assertMemoryHost(host) {
if (host == null || (host.conn === undefined && host.db === undefined)) {
throw new TypeError("DeltaSync host must expose an open Database on conn or db");
}
} Type guard
function isMemoryHost(host) {
return host != null && (host.conn !== undefined || host.db !== undefined);
} Try / catch
try {
const sync = new DeltaSync(memory);
} catch (err) {
if (err instanceof TypeError && err.message.includes("conn or db")) {
throw new Error("Open the memory database before constructing DeltaSync", { cause: err });
}
throw err;
} Prevention
- Open the database before constructing DeltaSync
- Pass the memory host instance, never a plain config/DTO object
- Don't serialize/deserialize objects carrying live Database handles
- Attach conn immediately after creating a memory object
When it happens
Trigger: new DeltaSync(memory) where memory is a plain object/DTO without conn or db; passing a config/options object instead of the memory instance; a memory object whose connection was closed and set to undefined; forgetting to open the database before constructing DeltaSync.
Common situations: Passing deserialized JSON of a memory (connection handle doesn't survive serialization); partially initialized memory objects during app startup; wiring mistakes where a settings object is passed instead of the memory; using an in-memory-only store that never had a Database attached.
Related errors
- missing {name}
- missing destination file operand after {}
- missing operand Try 'stat --help' for more information.
- No active model on agent
- No model configured
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/615a68a29d9089c1.
Report an issue: GitHub.