denoland/deno · error · TypeError
'Deno.AtomicOperation' is not a promise: did you forget to…
Error message
'Deno.AtomicOperation' is not a promise: did you forget to call 'commit()'
What it means
Deno.AtomicOperation is a builder, not a Promise. To make a forgotten commit() loud instead of a silent no-op, the class implements then() to throw TypeError("'Deno.AtomicOperation' is not a promise: did you forget to call 'commit()'") whenever the object is awaited or otherwise then-ed. Only commit() executes the queued checks/mutations/enqueues and returns {ok:true, versionstamp} or {ok:false}.
Solutions
- Terminate every chain with commit(): const res = await kv.atomic().set(k, v).commit().
- Check res.ok after commit — failed checks return {ok:false} rather than throwing.
- Grep your codebase for 'atomic()' usages not followed by commit() on the same statement.
- Wrap builder construction in small helper functions whose return type is the commit result, never the builder.
Example fix
// before
await kv.atomic().set(["a"], 1); // then() throws: forgot to call 'commit()'
// after
const res = await kv.atomic().set(["a"], 1).commit();
if (!res.ok) throw new Error("atomic commit failed"); Defensive patterns
Strategy: try-catch
Validate before calling
function commit(op: Deno.AtomicOperation): Promise<Deno.KvCommitResult | Deno.KvCommitError> {
return op.commit(); // the ONLY correct terminal call
} Type guard
const isAtomicOperation = (v: unknown): v is Deno.AtomicOperation => v instanceof Deno.AtomicOperation;
Try / catch
try {
await op; // if someone forgot .commit(), then() throws
} catch (e) {
if (e instanceof TypeError && e.message.includes("commit()")) {
throw new Error("atomic chain never committed — append .commit()");
}
throw e;
} Prevention
- End every kv.atomic() chain with .commit() on the same statement
- Check the returned {ok} flag after commit — failed checks do not throw
- Write helper functions whose return type is the commit result, never the builder
When it happens
Trigger: `await kv.atomic().set(k, v)` missing `.commit()`; returning the builder from an async function (implicit await); passing it to Promise.all(); calling `.then(...)` on the chain. The then() trap fires at await time, so the code fails before any write could be skipped silently.
Common situations: Chained-builder APIs invite awaiting the chain out of habit; refactors that split build and commit and dropped the terminal call; reviewers miss it because the line looks complete — without this guard the writes would silently never happen.
Related errors
- Invalid mutation 'delete' with value
- Invalid mutation type
- Invalid mutation ' ' without value
- batchSize must be a positive integer: received
- Cannot get cursor before first iteration
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/aac24780b8655917.
Report an issue: GitHub.
Appendix: source
Thrown at ext/kv/01_db.ts:596
opts?.keysIfUndelivered ?? [],
opts?.backoffSchedule ?? null,
]);
return this;
}
async commit(): Promise<Deno.KvCommitResult | Deno.KvCommitError> {
const versionstamp = await doAtomicWriteInPlace(
this.#rid,
this.#checks,
this.#mutations,
this.#enqueues,
);
if (versionstamp === null) return { ok: false };
return { ok: true, versionstamp };
}
then() {
throw new TypeError(
"'Deno.AtomicOperation' is not a promise: did you forget to call 'commit()'",
);
}
[SymbolFor("Deno.privateCustomInspect")](inspect, inspectOptions) {
const operations = [];
// Format checks
for (let i = 0; i < this.#checks.length; ++i) {
const check = this.#checks[i];
const key = check[0];
const versionstamp = check[1];
const keyStr = inspect(key, inspectOptions);
const versionstampStr = versionstamp === null
? "null"
: `"${versionstamp}"`;
ArrayPrototypePush(
operations,View on GitHub (pinned to 9ad36f7a2c)