-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Labels
Description
Related issues
None.
[REQUIRED] Version info
firebase-functions: 6.4.0
node:
v20.19.4
firebase-functions:
firebase-tools:
14.11.1
firebase-admin:
13.2.0
Test case
Firebase functions emulator entry point:
export * from '@my/apiOne';
export * from '@my/apiTwo';
@my/apiOne entry point:
import {
onInit
} from 'firebase-functions/v2/core';
import {
onRequest
} from 'firebase-functions/v2/https';
let value = null;
onInit(async () => {
value = await someLongProcess();
});
export const apiOne = onRequest({
cors: true
}, async (req, res) => {
return value.handler(req, res);
});
@my/apiTwo entry point:
import {
onInit
} from 'firebase-functions/v2/core';
import {
onRequest
} from 'firebase-functions/v2/https';
let value = null;
onInit(async () => {
value = await someLongProcess();
});
export const apiTwo = onRequest({
cors: true
}, async (req, res) => {
return value.handler(req, res);
});
Steps to reproduce
Break down code to contain functions separately yet have the emulator execute them singularly.
Expected behavior
onInit allows multiple calls where each async function passed is executed (await Promise.all(...);
).
This is required to break firebase code down into separate functions when running the emulator locally.
Actual behavior
Calling onInit more than once only calls the last function passed to it:
{"severity":"WARNING","message":"Setting onInit callback more than once. Only the most recent callback will be called"}
Were you able to successfully deploy your functions?
Deploy yes, run locally no. onInit functionality breaks using the emulators.