The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(plugins): handle a failed addon read while an earlier trip event still waits
Maurice807c6a16b4b8
diff --git a/server/src/nest/plugins/plugin-event-addons.ts b/server/src/nest/plugins/plugin-event-addons.tsindex cd5753e5c..5d38792c7 100644--- a/server/src/nest/plugins/plugin-event-addons.ts+++ b/server/src/nest/plugins/plugin-event-addons.ts@@ -49,7 +49,7 @@ export function tripEventSink(addons: AddonsService, orm: MikroORM | undefined,const before = queues.get(tripId);if (!addonId && !before) return deliver(tripId, event, meta);const ask = () => (addonId ? addons.isEnabledForTrip(tripId, addonId) : Promise.resolve(true));- const on = orm && addonId ? withRequestContext(orm, ask) : ask();+ const on = (orm && addonId ? withRequestContext(orm, ask) : ask()).catch(() => false);const queued = (before ?? Promise.resolve()).then(() => on).then((open) => {diff --git a/server/tests/unit/plugins/plugin-event-addons.test.ts b/server/tests/unit/plugins/plugin-event-addons.test.tsindex c36cf4684..3199d2120 100644--- a/server/tests/unit/plugins/plugin-event-addons.test.ts+++ b/server/tests/unit/plugins/plugin-event-addons.test.ts@@ -59,6 +59,34 @@ describe('the plugin event sink per trip', () => {expect(deliver).not.toHaveBeenCalled();});+ it('PEVADDON-004b: a read that fails while an earlier event of the trip still waits is handled at once', async () => {+ const deliver = vi.fn();+ const unhandled = vi.fn();+ process.on('unhandledRejection', unhandled);+ try {+ // A plain function, not vi.fn: a spy observes the promises it returns, which would handle the rejection itself.+ const answers: Array<(on: boolean) => void> = [];+ let reads = 0;+ const addons = {+ isEnabledForTrip: () =>+ reads++ === 0+ ? new Promise<boolean>((resolve) => answers.push(resolve))+ : Promise.reject(new Error('db gone')),+ } as unknown as AddonsService;+ const sink = tripEventSink(addons, undefined, deliver);+ sink(5, 'budget:updated', { v: 1 } as never);+ sink(5, 'budget:updated', { v: 2 } as never);+ await settle();+ await settle();+ expect(unhandled).not.toHaveBeenCalled();+ answers[0](true);+ await settle();+ expect(deliver.mock.calls.map(([, , meta]) => meta)).toEqual([{ v: 1 }]);+ } finally {+ process.off('unhandledRejection', unhandled);+ }+ });+it('PEVADDON-005: a trip keeps its emission order, though a later read answers first', async () => {const deliver = vi.fn();const answers: Array<(on: boolean) => void> = [];