fix: read-after-write issues (#215)

* fix: read-after-write issues

* fix: coderabbit comments

* fix: clear cache on invite

* fix: use primary after a read
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-10-31 09:56:07 +01:00
committed by GitHub
parent abacf66155
commit f454449365
19 changed files with 470 additions and 167 deletions

View File

@@ -0,0 +1,12 @@
import { AsyncLocalStorage } from 'node:async_hooks';
type Ctx = { sessionId: string | null };
export const als = new AsyncLocalStorage<Ctx>();
export const runWithAlsSession = <T>(
sid: string | null | undefined,
fn: () => Promise<T>,
) => als.run({ sessionId: sid || null }, fn);
export const getAlsSessionId = () => als.getStore()?.sessionId ?? null;