@alteran/astro 0.3.2 → 0.3.3
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 +1 -1
- package/src/worker/runtime.ts +9 -1
- package/src/worker/sequencer.ts +12 -0
package/package.json
CHANGED
package/src/worker/runtime.ts
CHANGED
|
@@ -79,8 +79,16 @@ export function createPdsFetchHandler(options?: CreatePdsFetchHandlerOptions): P
|
|
|
79
79
|
|
|
80
80
|
// Fire-and-forget: let relays know this PDS exists and is reachable.
|
|
81
81
|
// Throttled per isolate and safe to call frequently.
|
|
82
|
+
// Best-effort: notify relays, but avoid doing so on relay-initiated endpoints
|
|
83
|
+
// to prevent feedback loops (describeServer/subscribeRepos).
|
|
82
84
|
try {
|
|
83
|
-
|
|
85
|
+
const pathname = new URL(request.url).pathname;
|
|
86
|
+
const isRelayPath =
|
|
87
|
+
pathname === '/xrpc/com.atproto.server.describeServer' ||
|
|
88
|
+
pathname === '/xrpc/com.atproto.sync.subscribeRepos';
|
|
89
|
+
if (!isRelayPath) {
|
|
90
|
+
ctx.waitUntil(notifyRelaysIfNeeded(resolvedEnv as any, request.url));
|
|
91
|
+
}
|
|
84
92
|
} catch (err) {
|
|
85
93
|
// Never block on relay notification
|
|
86
94
|
}
|
package/src/worker/sequencer.ts
CHANGED
|
@@ -266,6 +266,16 @@ export class Sequencer {
|
|
|
266
266
|
console.error('Failed to send info frame:', error);
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
// Keep the connection alive to avoid intermediary idle timeouts (e.g., CF edge)
|
|
270
|
+
// Send a lightweight #info heartbeat every ~25s. Most clients ignore unknown #info
|
|
271
|
+
// messages; this is safe and keeps the socket active.
|
|
272
|
+
const keepalive = setInterval(() => {
|
|
273
|
+
try {
|
|
274
|
+
const ka = createInfoFrame('keepalive', 'ping');
|
|
275
|
+
ws.send(ka.toFramedBytes());
|
|
276
|
+
} catch {}
|
|
277
|
+
}, 25_000);
|
|
278
|
+
|
|
269
279
|
// Set up event handlers
|
|
270
280
|
ws.addEventListener('message', (evt) => {
|
|
271
281
|
try {
|
|
@@ -280,10 +290,12 @@ export class Sequencer {
|
|
|
280
290
|
|
|
281
291
|
ws.addEventListener('close', () => {
|
|
282
292
|
this.clients.delete(id);
|
|
293
|
+
clearInterval(keepalive);
|
|
283
294
|
});
|
|
284
295
|
|
|
285
296
|
ws.addEventListener('error', () => {
|
|
286
297
|
this.clients.delete(id);
|
|
298
|
+
clearInterval(keepalive);
|
|
287
299
|
});
|
|
288
300
|
|
|
289
301
|
// Replay buffered events if cursor provided
|