Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/vite/src/plugins/vite-plugin-cedar-universal-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,15 @@ async function generateFunctionModule(distPath: string): Promise<string> {
export default {
async fetch(request) {
const ctx = await buildCedarContext(request);
return _handler(request, ctx);
// Wrap the handler in an AsyncLocalStorage run so the global
// @cedarjs/context is available inside it (and isolated per request).
// Mirrors the GraphQL module above and the cedarContextWrappingPlugin
// used for non-UD builds.
const { getAsyncStoreInstance } = await import(
'@cedarjs/context/dist/store'
);
Comment thread
Tobbe marked this conversation as resolved.
const store = getAsyncStoreInstance();
return store.run(new Map(), () => _handler(request, ctx));
Comment thread
Tobbe marked this conversation as resolved.
}
};
`
Expand Down
Loading