fix: guard session projector against missing project FK

Same pattern as the message/part projectors — catch and log FK
constraint errors instead of throwing. Fixes flaky CI where test
ordering causes Session.create to fire before the project row exists.
This commit is contained in:
Kit Langton
2026-03-25 21:43:11 -04:00
parent 31299c6968
commit a9bde4a13d

View File

@@ -63,7 +63,12 @@ export function toPartialRow(info: DeepPartial<Session.Info>) {
export default [
SyncEvent.project(Session.Event.Created, (db, data) => {
db.insert(SessionTable).values(Session.toRow(data.info)).run()
try {
db.insert(SessionTable).values(Session.toRow(data.info)).run()
} catch (err) {
if (!foreign(err)) throw err
log.warn("ignored session create — project missing", { sessionID: data.info.id, projectID: data.info.projectID })
}
}),
SyncEvent.project(Session.Event.Updated, (db, data) => {