svelte-realtime 0.6.0-next.39 → 0.6.0-next.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/server/admin.js
CHANGED
|
@@ -101,13 +101,14 @@ export function _createAdminHandler(adminConfig) {
|
|
|
101
101
|
if (!store) return _json({ enabled: false, topic, count: 0, records: [] }, 200);
|
|
102
102
|
const lim = parseInt(url.searchParams.get('limit') || '', 10);
|
|
103
103
|
const limit = Number.isInteger(lim) && lim > 0 ? lim : 100;
|
|
104
|
-
|
|
104
|
+
// Store methods may be sync (in-memory) or async (Redis/Postgres); await tolerates both.
|
|
105
|
+
return _json({ enabled: true, topic, count: await store.count({ topic }), records: await store.list({ topic, limit }) }, 200);
|
|
105
106
|
}
|
|
106
107
|
if (pathname.endsWith('/dlq')) {
|
|
107
108
|
if (method !== 'GET') return _json({ error: 'method not allowed' }, 405);
|
|
108
109
|
const store = getDeadLetter();
|
|
109
110
|
if (!store) return _json({ enabled: false, total: 0, byTopic: {}, oldest: null, newest: null }, 200);
|
|
110
|
-
return _json({ enabled: true, ...store.summary() }, 200);
|
|
111
|
+
return _json({ enabled: true, ...(await store.summary()) }, 200);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
const sub = pathname.slice(pathname.lastIndexOf('/') + 1);
|
|
@@ -435,7 +435,11 @@ export async function _fireWebhookOut(entry, topic, event, data, platform) {
|
|
|
435
435
|
const store = state.webhookDeadLetter;
|
|
436
436
|
if (store) {
|
|
437
437
|
try {
|
|
438
|
-
|
|
438
|
+
// `add` may be sync (in-memory store) or async (a Redis/Postgres
|
|
439
|
+
// cluster store). Fire-and-forget either way - swallow a rejected
|
|
440
|
+
// promise so dead-letter capture can never break the (best-effort)
|
|
441
|
+
// webhook path or surface an unhandled rejection.
|
|
442
|
+
const added = store.add({
|
|
439
443
|
webhookId: entry.id,
|
|
440
444
|
topic,
|
|
441
445
|
event,
|
|
@@ -444,6 +448,7 @@ export async function _fireWebhookOut(entry, topic, event, data, platform) {
|
|
|
444
448
|
error: String((r.err && r.err.message) || r.err || 'unknown'),
|
|
445
449
|
failedAt: now()
|
|
446
450
|
});
|
|
451
|
+
if (added && typeof added.then === 'function') added.catch(() => {});
|
|
447
452
|
} catch { /* never let dead-letter capture break the (best-effort) webhook path */ }
|
|
448
453
|
}
|
|
449
454
|
}
|
package/src/server/webhooks.js
CHANGED
|
@@ -151,7 +151,9 @@ export async function replayDeadLetter(opts = {}) {
|
|
|
151
151
|
const dryRun = opts.dryRun === true;
|
|
152
152
|
if (!store) return { dryRun, total: 0, replayed: 0, removed: 0, results: [] };
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
// `list` / `remove` may be sync (in-memory) or async (a Redis/Postgres
|
|
155
|
+
// cluster store); awaiting tolerates both (await on a non-Promise is a no-op).
|
|
156
|
+
let records = await store.list({ topic: opts.topic, limit: 1000000 });
|
|
155
157
|
if (Array.isArray(opts.ids) && opts.ids.length) {
|
|
156
158
|
const want = new Set(opts.ids.map(String));
|
|
157
159
|
records = records.filter((r) => want.has(r.id));
|
|
@@ -180,7 +182,7 @@ export async function replayDeadLetter(opts = {}) {
|
|
|
180
182
|
}
|
|
181
183
|
if (outcome.ok) {
|
|
182
184
|
replayed++;
|
|
183
|
-
if (store.remove(rec.id)) removed++;
|
|
185
|
+
if (await store.remove(rec.id)) removed++;
|
|
184
186
|
results.push({ id: rec.id, ok: true, status: 'replayed' });
|
|
185
187
|
} else {
|
|
186
188
|
results.push({ id: rec.id, ok: false, status: 'failed', error: outcome.error });
|