aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2026-01-06 10:26:08 +0000
committerMohamed Bassem <me@mbassem.com>2026-01-10 15:13:05 +0000
commit4ba1475d4cf2fb31d85158a92c9fce0bb327c9b4 (patch)
tree9a26e0bfdfb6238ffbf888502d1a696424876791
parentaa7a81e0cad81f51ce21e2977c60ab4cb66e9e43 (diff)
downloadkarakeep-4ba1475d4cf2fb31d85158a92c9fce0bb327c9b4.tar.zst
fix: parallelize queue enqueues in bookmark routes
-rw-r--r--packages/trpc/routers/bookmarks.ts77
1 files changed, 42 insertions, 35 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts
index b28e7bf7..bf960748 100644
--- a/packages/trpc/routers/bookmarks.ts
+++ b/packages/trpc/routers/bookmarks.ts
@@ -320,22 +320,24 @@ export const bookmarksAppRouter = router({
}
}
- await triggerRuleEngineOnEvent(
- bookmark.id,
- [
- {
- type: "bookmarkAdded",
- },
- ],
- enqueueOpts,
- );
- await triggerSearchReindex(bookmark.id, enqueueOpts);
- await triggerWebhook(
- bookmark.id,
- "created",
- /* userId */ undefined,
- enqueueOpts,
- );
+ await Promise.all([
+ triggerRuleEngineOnEvent(
+ bookmark.id,
+ [
+ {
+ type: "bookmarkAdded",
+ },
+ ],
+ enqueueOpts,
+ ),
+ triggerSearchReindex(bookmark.id, enqueueOpts),
+ triggerWebhook(
+ bookmark.id,
+ "created",
+ /* userId */ undefined,
+ enqueueOpts,
+ ),
+ ]);
return bookmark;
}),
@@ -490,13 +492,14 @@ export const bookmarksAppRouter = router({
})),
);
}
- // Trigger re-indexing and webhooks
- await triggerSearchReindex(input.bookmarkId, {
- groupId: ctx.user.id,
- });
- await triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
- groupId: ctx.user.id,
- });
+ await Promise.all([
+ triggerSearchReindex(input.bookmarkId, {
+ groupId: ctx.user.id,
+ }),
+ triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
+ groupId: ctx.user.id,
+ }),
+ ]);
return updatedBookmark;
}),
@@ -535,12 +538,14 @@ export const bookmarksAppRouter = router({
),
);
});
- await triggerSearchReindex(input.bookmarkId, {
- groupId: ctx.user.id,
- });
- await triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
- groupId: ctx.user.id,
- });
+ await Promise.all([
+ triggerSearchReindex(input.bookmarkId, {
+ groupId: ctx.user.id,
+ }),
+ triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
+ groupId: ctx.user.id,
+ }),
+ ]);
}),
deleteBookmark: authedProcedure
@@ -976,12 +981,14 @@ Author: ${bookmark.author ?? ""}
summary: summary.response,
})
.where(eq(bookmarks.id, input.bookmarkId));
- await triggerSearchReindex(input.bookmarkId, {
- groupId: ctx.user.id,
- });
- await triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
- groupId: ctx.user.id,
- });
+ await Promise.all([
+ triggerSearchReindex(input.bookmarkId, {
+ groupId: ctx.user.id,
+ }),
+ triggerWebhook(input.bookmarkId, "edited", ctx.user.id, {
+ groupId: ctx.user.id,
+ }),
+ ]);
return {
bookmarkId: input.bookmarkId,