Files
accounted/lib/bookkeeping/actor-context-node.ts
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

20 lines
816 B
TypeScript

import { AsyncLocalStorage } from 'node:async_hooks'
import { bindActorStore, type CommitActor } from './actor-context'
/**
* Server-only half of the commit actor context (see ./actor-context for why
* the split exists). Importing this module binds the AsyncLocalStorage into
* the isomorphic registry so getActor() works wherever engine.ts runs on the
* server. Only ever import this from server-side code (pending-operation
* commit paths, API routes): never from anything reachable by a client
* component bundle.
*/
const actorStorage = new AsyncLocalStorage<CommitActor>()
bindActorStore(actorStorage)
/** Run fn with the given actor visible to getActor() across awaits. */
export function runWithActor<T>(actor: CommitActor, fn: () => Promise<T>): Promise<T> {
return actorStorage.run(actor, fn)
}