Skip to content

Commit 0b88c56

Browse files
committed
fix(shims): Naively polyfill AsyncLocalStorage in browser
1 parent be52a88 commit 0b88c56

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/agents-core/src/shims/shims-browser.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,16 @@ export const ReadableStreamController =
8787
export const TransformStream = globalThis.TransformStream;
8888

8989
export class AsyncLocalStorage {
90-
constructor() {}
91-
run() {}
92-
getStore() {}
93-
enterWith() {}
90+
context = null;
91+
constructor() { }
92+
run(context: any, fn: () => any) {
93+
this.context = context;
94+
return fn();
95+
}
96+
getStore() {
97+
return this.context;
98+
}
99+
enterWith() { }
94100
}
95101

96102
export function isBrowserEnvironment(): boolean {

0 commit comments

Comments
 (0)