aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-12-07 09:20:54 +0000
committerMohamed Bassem <me@mbassem.com>2025-12-07 09:20:54 +0000
commitcf2a12c8046b29c3fcf315d3a2598555175e1aee (patch)
tree5c49dc6924a91c8c3835857c0592deed2fca534e
parent6180c6622c88ca33d0d387a50be9036429281598 (diff)
downloadkarakeep-cf2a12c8046b29c3fcf315d3a2598555175e1aee.tar.zst
fix: remove queue triggers outside of updateTags transaction
-rw-r--r--packages/trpc/routers/bookmarks.ts34
1 files changed, 19 insertions, 15 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts
index f68d5ada..15ded2bd 100644
--- a/packages/trpc/routers/bookmarks.ts
+++ b/packages/trpc/routers/bookmarks.ts
@@ -711,7 +711,7 @@ export const bookmarksAppRouter = router({
)
.use(ensureBookmarkOwnership)
.mutation(async ({ input, ctx }) => {
- return ctx.db.transaction(async (tx) => {
+ const res = await ctx.db.transaction(async (tx) => {
// Detaches
const idsToRemove: string[] = [];
if (input.detach.length > 0) {
@@ -822,28 +822,32 @@ export const bookmarksAppRouter = router({
),
);
- await triggerRuleEngineOnEvent(input.bookmarkId, [
- ...idsToRemove.map((t) => ({
+ return {
+ bookmarkId: input.bookmarkId,
+ attached: allIds,
+ detached: idsToRemove,
+ };
+ });
+
+ await Promise.allSettled([
+ triggerRuleEngineOnEvent(input.bookmarkId, [
+ ...res.detached.map((t) => ({
type: "tagRemoved" as const,
tagId: t,
})),
- ...allIds.map((t) => ({
+ ...res.attached.map((t) => ({
type: "tagAdded" as const,
tagId: t,
})),
- ]);
- await triggerSearchReindex(input.bookmarkId, {
+ ]),
+ triggerSearchReindex(input.bookmarkId, {
groupId: ctx.user.id,
- });
- await triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
+ }),
+ triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
groupId: ctx.user.id,
- });
- return {
- bookmarkId: input.bookmarkId,
- attached: allIds,
- detached: idsToRemove,
- };
- });
+ }),
+ ]);
+ return res;
}),
getBrokenLinks: authedProcedure
.output(