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(offline): park a queued delete that a switched-off addon refuses
Maurice56ce66f66699
diff --git a/client/src/sync/mutationQueue.ts b/client/src/sync/mutationQueue.tsindex 05ba4a3dc..e721513ea 100644--- a/client/src/sync/mutationQueue.ts+++ b/client/src/sync/mutationQueue.ts@@ -248,6 +248,8 @@ const TEMP_REF_LISTS = ['orderedIds'] as const// day, the walk or the stop (TripAccessGuard, TourVisitsService). Any other 404,// the Tours addon turned off among them, fails like any other refusal.const GONE_WALK_PARTS = new Set(['Trip not found', 'Assignment not found', 'City walk not found', 'Station not found'])+// The 404 of a route whose addon is off (AddonGuard, TripAddonGuard).+const ADDON_OFF = / addon is not enabled$//*** The body with every link to an offline-created entity pointed at the real id@@ -427,14 +429,15 @@ async function reconcileStationVisits(mutation: QueuedMutation, data: unknown, a/*** A 404 that means the write did what it set out to do: a DELETE of something* the server no longer has, or a mark of a walk's stop whose stop, day, walk or- * trip is gone, since its visits went with it.+ * trip is gone, since its visits went with it. An addon switched off for the+ * trip or the instance keeps the entity, so that 404 is a refusal.*/function doneByNotFound(mutation: QueuedMutation, err: unknown): boolean {- if (mutation.method === 'DELETE') return true- if (mutation.resource !== 'tourStationVisits') return false// Called on a 404 only, so the server answered.const reason = (err as { response: { data?: { error?: unknown } } }).response.data?.error- return typeof reason === 'string' && GONE_WALK_PARTS.has(reason)+ if (typeof reason === 'string' && ADDON_OFF.test(reason)) return false+ if (mutation.method === 'DELETE') return true+ return mutation.resource === 'tourStationVisits' && typeof reason === 'string' && GONE_WALK_PARTS.has(reason)}/** Visits, days, day notes, the trip itself and a walk's marks, each from the answer its route gives. */diff --git a/client/tests/unit/sync/mutationQueue.test.ts b/client/tests/unit/sync/mutationQueue.test.tsindex dfd8bbc96..3b1f78c5b 100644--- a/client/tests/unit/sync/mutationQueue.test.ts+++ b/client/tests/unit/sync/mutationQueue.test.ts@@ -561,6 +561,23 @@ describe('mutationQueue.flush: a write the server keeps failing on', () => {expect(await offlineDb.places.get(5)).toBeUndefined();expect(await mutationQueue.failedCount()).toBe(0);});++ it.each([+ { resource: 'packingItems', url: '/trips/1/packing/5', label: 'Packing' },+ { resource: 'budgetItems', url: '/trips/1/budget/5', label: 'Costs' },+ { resource: 'tripFiles', url: '/trips/1/files/5/permanent', label: 'Documents' },+ { resource: undefined, url: '/trips/1/files/trash/empty', label: 'Documents' },+ ])('parks a DELETE of $url that the $label addon being off refuses', async ({ resource, url, label }) => {+ const id = generateUUID();+ const entityId = resource ? 5 : undefined;+ await mutationQueue.enqueue(makeMutation({ id, method: 'DELETE', url, body: undefined, resource, entityId }));++ server.use(http.delete(`/api${url}`, () => HttpResponse.json({ error: `${label} addon is not enabled` }, { status: 404 })));+ await mutationQueue.flush();++ expect(await offlineDb.mutationQueue.get(id)).toMatchObject({ status: 'failed', attempts: 1 });+ expect(await mutationQueue.failedCount()).toBe(1);+ });});describe('mutationQueue: parked changes', () => {