(feat) initializeServerApp support for App Hosting auto init#9151
(feat) initializeServerApp support for App Hosting auto init#9151DellaBitta merged 12 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 8d93ef2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
| /** | ||
| * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance. | ||
| * | ||
| * @param config - Optional `FirebaseServerApp` configuration. | ||
| * | ||
| * @returns The initialized `FirebaseServerApp`. | ||
| * | ||
| * @public | ||
| */ |
There was a problem hiding this comment.
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} - ...
packages/app/src/api.ts
Outdated
|
|
||
| if (_options) { | ||
| if (_isFirebaseApp(_options)) { | ||
| app = _options; |
There was a problem hiding this comment.
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.
| throw ERROR_FACTORY.create(AppError.INVALID_SERVER_APP_ENVIRONMENT); | ||
| } | ||
|
|
||
| if (_serverAppConfig.automaticDataCollectionEnabled === undefined) { |
There was a problem hiding this comment.
Are we getting rid of this? Should this go in the second branch of the if/else? Maybe also the third?
There was a problem hiding this comment.
Yes, thank you, nice catch!
egilmorez
left a comment
There was a problem hiding this comment.
LGTM!
Would this have any impact on https://firebase.devsite.corp.google.com/docs/app-hosting/firebase-sdks or other App Hosting pages? Or possibly https://firebase.google.com/docs/web/ssr-apps?
Yes, I think that page should be updated. Both the "Automatically initialize Firebase Admin SDK and web SDKs" and "Use FirebaseServerApp for SSR" sections. Hit up @jamesdaniels and me to get the ball rolling there.
I don't think this page needs any updates. It doesn't mention auto-initialization at all, and I don't think we want to push for its usage outside of App Hosting context. |
Discussion
Implement Auto Init for
initializeServerApp.Auto init was previously implemented for
initializeAppin #8483. This PR adds the same functionality to theinitializeServerAppAPI surface.Fixes #8863.
Testing
Local testing in Node and a Next.js app.
API Changes
Internal doc: Firebase API - JS SDK initializeServerApp auto init