CI / Build & Quality Checks (pull_request) Successful in 3m12s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 9s
CI / Playwright smoke (e2e) (pull_request) Successful in 15m31s
During a homeserver stall Element Call retries update_delayed_event every 2 s, and the host opened a new HTTP request each time: 12 pending in a 60 s stall, all landing together on recovery (404 x5, 429 x7). Share the in-flight restart per delay id and abort it after 5 s. Refs #318 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
15 lines
503 B
TypeScript
15 lines
503 B
TypeScript
/**
|
|
* Share one in-flight promise per key: callers that ask again while a request
|
|
* for the same key is still pending get that request instead of a new one.
|
|
*/
|
|
export function dedupeInFlight<T>(): (key: string, run: () => Promise<T>) => Promise<T> {
|
|
const pending = new Map<string, Promise<T>>();
|
|
return (key, run) => {
|
|
const existing = pending.get(key);
|
|
if (existing) return existing;
|
|
const p = run().finally(() => pending.delete(key));
|
|
pending.set(key, p);
|
|
return p;
|
|
};
|
|
}
|