(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 }})

@DellaBitta

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

@changeset-bot

@google-oss-bot

Size Report 1

Affected Products

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%)
Type Base (f11b552) Merge (bb0c09f) Diff
main 366 kB 367 kB +549 B (+0.1%)
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

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/BqeCLNTixZ.html

@google-oss-bot

Size Analysis Report 1

Affected Products

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/0K78QF6kMU.html

@DellaBitta

@DellaBitta

@DellaBitta DellaBitta changed the title(feat) initializeServerApp support for App Hosting Auto Init (feat) initializeServerApp support for App Hosting auto init

Jul 7, 2025

dlarocque

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} - ... 

hsubox76

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.

@DellaBitta

@DellaBitta

@DellaBitta

hsubox76

@DellaBitta

egilmorez

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DellaBitta

@DellaBitta

dlarocque

@DellaBitta

@firebase firebase locked and limited conversation to collaborators

Aug 11, 2025