( sid: string | null | undefined, fn: () => Promise<T>, )
| 5 | export const als = new AsyncLocalStorage<Ctx>(); |
| 6 | |
| 7 | export const runWithAlsSession = <T>( |
| 8 | sid: string | null | undefined, |
| 9 | fn: () => Promise<T>, |
| 10 | ) => als.run({ sessionId: sid || null }, fn); |
| 11 | |
| 12 | export const getAlsSessionId = () => als.getStore()?.sessionId ?? null; |