(feat) initializeServerApp support for App Hosting auto init by DellaBitta · Pull Request #9151 · firebase/firebase-js-sdk (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Discussion
Implement Auto Init for initializeServerApp.
Auto init was previously implemented for initializeApp in #8483. This PR adds the same functionality to the initializeServerApp API surface.
Fixes #8863.
Testing
Local testing in Node and a Next.js app.
API Changes
Internal doc: Firebase API - JS SDK initializeServerApp auto init
Size Report 1
Affected Products
@firebase/app
| Type | Base (f11b552) | Merge (bb0c09f) | Diff |
|---|---|---|---|
| browser | 19.5 kB | 20.0 kB | +507 B (+2.6%) |
| main | 20.4 kB | 20.9 kB | +549 B (+2.7%) |
| module | 19.5 kB | 20.0 kB | +507 B (+2.6%) |
| react-native | 20.4 kB | 20.9 kB | +549 B (+2.7%) |
@firebase/database-compat/standalone
| Type | Base (f11b552) | Merge (bb0c09f) | Diff |
|---|---|---|---|
| main | 366 kB | 367 kB | +549 B (+0.1%) |
firebase
| Type | Base (f11b552) | Merge (bb0c09f) | Diff |
|---|---|---|---|
| firebase-app-compat.js | 31.8 kB | 32.0 kB | +232 B (+0.7%) |
| firebase-app.js | 103 kB | 104 kB | +928 B (+0.9%) |
| firebase-compat.js | 806 kB | 807 kB | +235 B (+0.0%) |
| firebase-performance-standalone-compat.js | 105 kB | 106 kB | +237 B (+0.2%) |
Test Logs
- Base (f11b552): https://github.com/firebase/firebase-js-sdk/actions/runs/16227224067
- Merge (bb0c09f): https://github.com/firebase/firebase-js-sdk/actions/runs/16228602698
Size Analysis Report 1
Affected Products
@firebase/app_isFirebaseServerAppSettings
Size
Type Base (f11b552) Merge (bb0c09f) Diff size ? 8.82 kB ? (?) size-with-ext-deps ? 18.3 kB ? (?) Dependency Type Base (f11b552) Merge (bb0c09f) Diff --------- ------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- functions ? 15 dependencies_addComponent _isFirebaseApp _isFirebaseServerAppSettings _registerComponent computeKey countBytes extractHeartbeatsForHeader getDbPromise getEarliestHeartbeatIdx getUTCDateString isVersionServiceProvider readHeartbeatsFromIndexedDB registerCoreComponents registerVersion writeHeartbeatsToIndexedDB ? classes ? HeartbeatServiceImpl HeartbeatStorageImpl PlatformLoggerServiceImpl ? variables ? 41 dependenciesDB_NAME DB_VERSION ERRORS ERROR_FACTORY MAX_HEADER_BYTES MAX_NUM_STORED_HEARTBEATS PLATFORM_LOG_STRING STORE_NAME _apps _components _serverApps dbPromise logger name name$1 name$2 name$3 name$4 name$5 name$6 name$7 name$8 name$9 name$a name$b name$c name$d name$e name$f name$g name$h name$i name$j name$k name$l name$m name$n name$o name$p name$q version$1 ? enums ? ? External Dependency Module Base (f11b552) Merge (bb0c09f) Diff ------------------- ------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------- ---- @firebase/component ? Component ? @firebase/logger ? Logger ? @firebase/util ? ErrorFactory FirebaseError base64urlEncodeWithoutPadding isIndexedDBAvailable validateIndexedDBOpenable ? idb ? openDB ? initializeServerApp
Size
Type Base (f11b552) Merge (bb0c09f) Diff size 12.3 kB 12.6 kB +258 B (+2.1%) size-with-ext-deps 26.3 kB 27.4 kB +1.04 kB (+4.0%) Dependency Type Base (f11b552) Merge (bb0c09f) Diff --------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------- functions 17 dependencies_addComponent _isFirebaseApp _registerComponent computeKey countBytes deleteApp extractHeartbeatsForHeader getDbPromise getEarliestHeartbeatIdx getUTCDateString initializeServerApp isVersionServiceProvider readHeartbeatsFromIndexedDB registerCoreComponents registerVersion validateTokenTTL writeHeartbeatsToIndexedDB 18 dependencies_addComponent _isFirebaseApp _isFirebaseServerAppSettings _registerComponent computeKey countBytes deleteApp extractHeartbeatsForHeader getDbPromise getEarliestHeartbeatIdx getUTCDateString initializeServerApp isVersionServiceProvider readHeartbeatsFromIndexedDB registerCoreComponents registerVersion validateTokenTTL writeHeartbeatsToIndexedDB + _isFirebaseServerAppSettings External Dependency Module Base (f11b552) Merge (bb0c09f) Diff -------------- ------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------- @firebase/util ErrorFactory FirebaseError base64Decode base64urlEncodeWithoutPadding isBrowser isIndexedDBAvailable isWebWorker validateIndexedDBOpenable ErrorFactory FirebaseError base64Decode base64urlEncodeWithoutPadding getDefaultAppConfig isBrowser isIndexedDBAvailable isWebWorker validateIndexedDBOpenable + getDefaultAppConfig
Test Logs
- Base (f11b552): https://github.com/firebase/firebase-js-sdk/actions/runs/16227224067
- Merge (bb0c09f): https://github.com/firebase/firebase-js-sdk/actions/runs/16228602698
DellaBitta changed the title
(feat) initializeServerApp support for App Hosting Auto Init (feat) initializeServerApp support for App Hosting auto init
Comment on lines 235 to 243
| /** |
|---|
| * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance. |
| * |
| * @param config - Optional `FirebaseServerApp` configuration. |
| * |
| * @returns The initialized `FirebaseServerApp`. |
| * |
| * @public |
| */ |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's useful to add @throws tag on functions that throw, but the other functions in app don't do this, so maybe it'd just make it inconsistent which may be worse- feel free to ignore.
@throws {AppError.INVALID_SERVER_APP_ENVIRONMENT} - ...
| if (_options) { |
| if (_isFirebaseApp(_options)) { |
| app = _options; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is the only place the app variable is used, probably don't need to initialize it with the let above in line 256.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| throw ERROR_FACTORY.create(AppError.INVALID_SERVER_APP_ENVIRONMENT); |
|---|
| } |
| if (_serverAppConfig.automaticDataCollectionEnabled === undefined) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we getting rid of this? Should this go in the second branch of the if/else? Maybe also the third?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you, nice catch!
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firebase locked and limited conversation to collaborators