今後Firebaseの機能を使用する必要があるため、
initializeAppを使いつつデプロイを成功させたいです。
initializeAppのある/なしでデプロイに成功/失敗します。
(initializeAppをコメントアウトすると成功します。)
firebase emulators:start
によるローカルでの実行は成功しています。
原因等思い当たることがあればご教授いただけないでしょうか。
command
firebase deploy --only functions
error
~
"error":{"code":3,"message":"Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."}}
[debug] [2022-04-20T11:59:45.071Z] Got source token 4a2e343d-2d38-45bf-b356-dfbee943ac68 for region us-central1
[debug] [2022-04-20T11:59:45.080Z] Total Function Deployment time: 91338
[debug] [2022-04-20T11:59:45.080Z] 1 Functions Deployed
[debug] [2022-04-20T11:59:45.080Z] 1 Functions Errored
[debug] [2022-04-20T11:59:45.081Z] 0 Function Deployments Aborted
[debug] [2022-04-20T11:59:45.081Z] Average Function Deployment time: 91335
[info]
[info] Functions deploy had errors with the following functions:
api(us-central1)
[debug] [2022-04-20T11:59:45.084Z] Missing URI for HTTPS function in printTriggerUrls. This shouldn't happen
[info] i functions: cleaning up build files...
~
[debug] [2022-04-20T11:59:51.612Z] Error: Failed to update function api in region us-central1
at /usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:38:11
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Fabricator.updateV1Function (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:268:32)
at async Fabricator.updateEndpoint (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:134:13)
at async handle (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:75:17)
[error]
[error] Error: There was an error deploying functions
- code
import cors from 'cors';
import { https } from 'firebase-functions';
import { initializeApp, App } from 'firebase-admin/app';
import express, { Request, Response } from 'express';
const firebaseApp: App = initializeApp();
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors({ origin: true }));
app.post('/', (req: Request, res: Response) => {
res.send(200);
});
const api = https.onRequest(app);
export { api };
- versions
Node: 16.14.2
firebase-tools: 10.6.0
cors: 2.8.5
express: 4.17.3
firebase-admin: 10.0.2
firebase-functions: 3.20.1