File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ import {
48
48
LogOptions ,
49
49
setUserLogHandler
50
50
} from '@firebase/logger' ;
51
- import { deepEqual , getDefaultAppConfig } from '@firebase/util' ;
51
+ import { deepEqual , getDefaultAppConfig , isBrowser } from '@firebase/util' ;
52
52
53
53
export { FirebaseError } from '@firebase/util' ;
54
54
@@ -229,6 +229,11 @@ export function initializeServerApp(
229
229
_options : FirebaseOptions | FirebaseApp ,
230
230
_serverAppConfig : FirebaseServerAppSettings
231
231
) : FirebaseServerApp {
232
+ if ( isBrowser ( ) ) {
233
+ // FirebaseServerApps aren't designed to be run in browsers.
234
+ throw ERROR_FACTORY . create ( AppError . INVALID_SERVER_APP_ENVIRONMENT ) ;
235
+ }
236
+
232
237
const serverAppSettings : FirebaseServerAppSettings = {
233
238
automaticDataCollectionEnabled : false ,
234
239
..._serverAppConfig
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ export const enum AppError {
30
30
IDB_GET = 'idb-get' ,
31
31
IDB_WRITE = 'idb-set' ,
32
32
IDB_DELETE = 'idb-delete' ,
33
- FINALIZATION_REGISTRY_NOT_SUPPORTED = 'finalization-registry-not-supported'
33
+ FINALIZATION_REGISTRY_NOT_SUPPORTED = 'finalization-registry-not-supported' ,
34
+ INVALID_SERVER_APP_ENVIRONMENT = 'invalid-server-app-environment'
34
35
}
35
36
36
37
const ERRORS : ErrorMap < AppError > = {
@@ -58,7 +59,9 @@ const ERRORS: ErrorMap<AppError> = {
58
59
[ AppError . IDB_DELETE ] :
59
60
'Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.' ,
60
61
[ AppError . FINALIZATION_REGISTRY_NOT_SUPPORTED ] :
61
- "FirebaseServerApp '{$appName}' deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry."
62
+ 'FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.' ,
63
+ [ AppError . INVALID_SERVER_APP_ENVIRONMENT ] :
64
+ 'FirebaseServerApp is not for use in browser environments.'
62
65
} ;
63
66
64
67
interface ErrorParams {
Original file line number Diff line number Diff line change 2
2
"extends" : " ../../config/tsconfig.base.json" ,
3
3
"compilerOptions" : {
4
4
"outDir" : " dist" ,
5
- "downlevelIteration" : true ,
6
- "lib" : [" ESNext" ],
5
+ "downlevelIteration" : true
7
6
},
8
7
"exclude" : [
9
8
" dist/**/*"
You can’t perform that action at this time.
0 commit comments