mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-24 06:45:22 +00:00
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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user