Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/api/src/middleware/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class Tracker {
sql`coalesce((data->'lastSeen')::bigint, 0) < ${lastSeen}`,
],
{ lastSeen },
// lastSeen is best-effort: the record may have been deleted since the
// token was last seen, so a no-op update is not an error.
{ throwIfEmpty: false },
);
} catch (err) {
console.log(
Expand Down
6 changes: 5 additions & 1 deletion packages/api/src/store/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ export default class Table<T extends DBObject> {
}

if (res.rowCount < 1 && throwIfEmpty) {
throw new NotFoundError(`${this.name} id=${doc.id} not found`);
// When query is an array of SQL conditions, doc may not contain an id.
// Fall back to a generic message to avoid misleading "id=undefined" errors.
const idHint =
typeof query === "string" ? query : (doc as any).id ?? "(unknown)";
throw new NotFoundError(`${this.name} id=${idHint} not found`);
}
return res;
}
Expand Down
Loading