firebase / firebase/firebase-tools
Downgrading v2 function to v1 function fails in unexpected way
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### [REQUIRED] Environment info
**firebase-tools: 11.21.0**
**Platform: MacOS**
### [REQUIRED] Test case
Deps:
```
"firebase-admin": "^11.3.0",
"firebase-functions": "^4.2.0",
```
Try deploying the following function:
```ts
import { user } from "firebase-functions/v1/auth";
import { db } from "./setup/db";
import { firestore } from "firebase-admin";
import { logger } from "firebase-functions/v1";
import {
AuthEventContext,
AuthUserRecord,
} from "firebase-functions/lib/common/providers/identity";
export const syncUserToDb = user().beforeCreate(
async (user: AuthUserRecord, context: AuthEventContext) => {
const uid = user.uid;
// Sync to user table.
await db.doc(`users/${uid}`).create({
uid,
displayName: defaultName,
email: user.email,
creationTime: firestore.FieldValue.serverTimestamp(),
lastSignInTime: firestore.FieldValue.serverTimestamp(),
});
logger.info(`Added user ${uid} to table`);
}
);
```
### [REQUIRED] Steps to reproduce
Try deploying the above function.
### [REQUIRED] Expected behavior
Should be able to deploy
### [REQUIRED] Actual behavior
Got the following error:
```
Error: Cannot set CPU on the functions syncusertodb because they are GCF gen 1
```
Think it comes from here:
https://github.com/firebase/firebase-tools/blob/ad99ec653a6e8486f28ef97bcc9471a83dc0268b/src/deploy/functions/validate.ts#L14
Contributor guide
Research direction
Start in src/deploy/functions/validate.ts around line 14, then reproduce the deployment with the TypeScript function and dependency versions shown in the issue. Trace why the v1 function is rejected for CPU configuration; done means the reported v1 deployment no longer fails with the GCF gen 1 CPU error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- firebase, typescript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100