mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
Serialize gate confirmation mirror writes
This commit is contained in:
2 files changed
+14
-6
No files matched your search
@@ -2957,7 +2957,13 @@ describeEmbeddedPostgres("issueService.create workspace inheritance", () => {
|
||||
body: `A user pasted the mirror marker: <!-- gate-confirmation-mirror:${child.id} -->`,
|
||||
});
|
||||
|
||||
const mirrored = await svc.mirrorGateConfirmationToParent(child.id);
|
||||
const mirrorResults = await Promise.all([
|
||||
svc.mirrorGateConfirmationToParent(child.id),
|
||||
svc.mirrorGateConfirmationToParent(child.id),
|
||||
]);
|
||||
expect(mirrorResults.filter(Boolean)).toHaveLength(1);
|
||||
expect(mirrorResults.filter((result) => result === null)).toHaveLength(1);
|
||||
const mirrored = mirrorResults.find(Boolean);
|
||||
expect(mirrored).toMatchObject({
|
||||
issueId: parentIssueId,
|
||||
authorType: "system",
|
||||
|
||||
@@ -4645,8 +4645,8 @@ export function issueService(db: Db) {
|
||||
};
|
||||
},
|
||||
|
||||
mirrorGateConfirmationToParent: async (childIssueId: string) => {
|
||||
const child = await db
|
||||
mirrorGateConfirmationToParent: async (childIssueId: string) => db.transaction(async (tx) => {
|
||||
const child = await tx
|
||||
.select({
|
||||
id: issues.id,
|
||||
companyId: issues.companyId,
|
||||
@@ -4658,6 +4658,7 @@ export function issueService(db: Db) {
|
||||
})
|
||||
.from(issues)
|
||||
.where(eq(issues.id, childIssueId))
|
||||
.for("update")
|
||||
.then((rows) => rows[0] ?? null);
|
||||
if (!child || child.status !== "done" || !child.parentId) return null;
|
||||
|
||||
@@ -4665,7 +4666,7 @@ export function issueService(db: Db) {
|
||||
if (!mirror || mirror.parentIssueId !== child.parentId) return null;
|
||||
|
||||
const marker = buildGateConfirmationMirrorMarker(child.id);
|
||||
const existingMirror = await db
|
||||
const existingMirror = await tx
|
||||
.select({ id: issueComments.id })
|
||||
.from(issueComments)
|
||||
.where(and(
|
||||
@@ -4678,7 +4679,7 @@ export function issueService(db: Db) {
|
||||
.then((rows) => rows[0] ?? null);
|
||||
if (existingMirror) return null;
|
||||
|
||||
const latestChildComment = await db
|
||||
const latestChildComment = await tx
|
||||
.select({ body: issueComments.body })
|
||||
.from(issueComments)
|
||||
.where(and(
|
||||
@@ -4700,8 +4701,9 @@ export function issueService(db: Db) {
|
||||
}),
|
||||
{},
|
||||
{ authorType: "system" },
|
||||
tx,
|
||||
);
|
||||
},
|
||||
}),
|
||||
|
||||
createChild: async (
|
||||
parentIssueId: string,
|
||||
|
||||
Reference in new issue
Block a user