Skip to content

Commit f4e8055

Browse files
committed
fix: polyfill process.on to prevent initialization errors in browser environment
1 parent 0510eac commit f4e8055

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/console/src/mocks/browser.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ let kernel: ObjectKernel | null = null;
1515
let driver: InMemoryDriver | null = null;
1616

1717
export async function startMockServer() {
18+
// Polyfill process.on for ObjectKernel in browser environment
19+
// This prevents the "process.on is not a function" error when ObjectKernel initializes
20+
try {
21+
if (typeof process !== 'undefined' && !(process as any).on) {
22+
(process as any).on = () => {};
23+
}
24+
} catch (e) {
25+
console.warn('[MSW] Failed to polyfill process.on', e);
26+
}
27+
1828
if (kernel) {
1929
console.log('[MSW] ObjectStack Runtime already initialized');
2030
return kernel;

0 commit comments

Comments
 (0)