Skip to content

Commit

Permalink
fix: server app should initialize in web workers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseVSeb committed Jun 27, 2024
1 parent baa96ce commit 3a2a1ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-mayflies-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/app': patch
---

fix: server app should initialize in web workers
9 changes: 7 additions & 2 deletions packages/app/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ import {
LogOptions,
setUserLogHandler
} from '@firebase/logger';
import { deepEqual, getDefaultAppConfig, isBrowser } from '@firebase/util';
import {
deepEqual,
getDefaultAppConfig,
isBrowser,
isWebWorker
} from '@firebase/util';

export { FirebaseError } from '@firebase/util';

Expand Down Expand Up @@ -230,7 +235,7 @@ export function initializeServerApp(
_options: FirebaseOptions | FirebaseApp,
_serverAppConfig: FirebaseServerAppSettings
): FirebaseServerApp {
if (isBrowser()) {
if (isBrowser() && !isWebWorker()) {
// FirebaseServerApp isn't designed to be run in browsers.
throw ERROR_FACTORY.create(AppError.INVALID_SERVER_APP_ENVIRONMENT);
}
Expand Down

0 comments on commit 3a2a1ba

Please sign in to comment.