A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: parallelize queue enqueues in bookmark routes
Mohamed Bassem4ba1475d4cf2
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.tsindex 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,