Comments (15)
Using TypeScript.
My issue was that the "main" field in package.json got out of sync with how my project developed. Because of that, firebase kept deploying my old code and not uploading the new code generated from "tsc". I wont get into the nitty gritty out of my project, but to others I would advise to make sure that your "main" field in your package.json actually points to the correct index.js of your /lib folder.
"main": "lib/wherever/the/correct//index.js/is/for/you",
from firebase-functions.
Using TypeScript.
My issue was that the "main" field in package.json got out of sync with how my project developed. Because of that, firebase kept deploying my old code and not uploading the new code generated from "tsc". I wont get into the nitty gritty out of my project, but to others I would advise to make sure that your "main" field in your package.json actually points to the correct index.js of your /lib folder.
"main": "lib/wherever/the/correct//index.js/is/for/you",
Ok, this was the solution for me, Thanks!
this are the steps I did to make this work:
- Everything inside
functions
folder - deleted
lib
folder (this helped me to realize of the old code and the new one) yarn build
- Point
package.json -> "main"
to the right entrey point, in my case"main": "lib/src/index.js"
firebase deploy --only functions
Thank you again for pointing me the solution, it will take ages to figure out.
then everything was updated
from firebase-functions.
Thanks for the link! If you follow the conversation, in googleapis/google-auth-library-nodejs#320 (comment), @jkoelker has found that this error message is caused by unreturned promises. In that case it was the spanner library, but in your case I see at least 2 lines where you are missing a return
at the beginning of the statement:
admin.firestore().collection('companies').doc(companyID)
client.messages.create(textMessage).then( response => {
from firebase-functions.
Could you try running npm run build
in your functions folder prior to running firebase deploy
to ensure that your source code is compiled?
from firebase-functions.
Did you change the file name at all? Or add anything new to firebase.json?
from firebase-functions.
I deleted firebase.json and started over. Then it worked.
from firebase-functions.
I'm having the same issue... I've been successfully deploying my functions and yet no changes are taking effect. Not sure what to do...
from firebase-functions.
@paujur Are you using TypeScript? As well, do you actually get success message saying which functions were updated? If the Firebase CLI was unable to find any functions, it will also print a successfully deployed message, but with no mention of specific functions (so essentially it successfully deployed, but it deployed nothing)
from firebase-functions.
@laurenzlong Yes, I'm using Typescript. So I just went through the whole process again. First tested as is, it failed as it should have (since it wasn't updated yet). Then ran the deploy again, everything was successful, but the function did not deploy changes. Here are the console outputs: https://cl.ly/22370W3o1H0k & https://cl.ly/2B3n3p3Q1332 -> same things were logged to the console, even though I deleted all console logs (among other changes). Also, for some odd reason the last error was logged multiple times. But that's a fluke.
Here you can see that the sendMessage
function was deployed successfully: https://cl.ly/0J2i453N0O3R
And here is my sendMessage function:
`
export const sendMessage = functions.https.onCall((data, context ) => {
// Message text passed from the client.
const message = data.message;
const text = message.text;
const phoneNumber = data.phoneNumber;
const companyID = data.companyID;
const teamID = data.teamID;
let accountSid: string;
let authToken: string;
// TODO: maybe figure out the type here...
let client: any;
admin.firestore().collection('companies').doc(companyID)
.get().then( companyDoc => {
const companyData = companyDoc.data();
accountSid = companyData.twilioSid;
authToken = companyData.twilioAuthToken;
client = new twilio(accountSid, authToken);
admin.firestore().collection('companies').doc(companyID).collection('teams').doc(teamID)
.get().then( teamDoc => {
const teamData = teamDoc.data();
const twilioNumber = teamData.twilioPhoneNumber;
if ( !validE164(phoneNumber) ) {
throw new Error('number must be E164 format!')
}
const textMessage = {
body: text,
to: phoneNumber, // Text to this number
from: twilioNumber // From a valid Twilio number
};
client.messages.create(textMessage).then( response => {
// console.log(response.sid, 'success');
return { 'success': response };
}
).catch(err => {
// console.log(err);
return {'error': err };
})
});
});
/// Validate E164 format
function validE164(num) {
return /^\+?[1-9]\d{1,14}$/.test(num)
}
} );
`
I even waited 15 minutes to make sure everything is deployed properly. Sometimes, when I try to run the function too soon after deployment I get this error:
Error: Unexpected error while acquiring application default credentials: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information. at GoogleAuth.<anonymous> (/user_code/node_modules/firebase-admin/node_modules/google-auth-library/build/src/auth/googleauth.js:248:31) at step (/user_code/node_modules/firebase-admin/node_modules/google-auth-library/build/src/auth/googleauth.js:47:23) at Object.next (/user_code/node_modules/firebase-admin/node_modules/google-auth-library/build/src/auth/googleauth.js:28:53) at fulfilled (/user_code/node_modules/firebase-admin/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58) at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Any ideas? Was ripping my hair out for a while not realizing that it wasn't deploying correctly to begin with haha.
from firebase-functions.
@laurenzlong It's possible I'm just being silly and doing something dumb ha... any thoughts?
from firebase-functions.
@laurenzlong Yes, it builds correctly. But I think I may have an idea of what's going on... It seems like every time I deploy the function and then go to use it, I get an error about the credentials missing. Which shouldn't be the case because the default credentials should be pulled I believe. So I'm thinking that somehow the credentials either aren't being pulled, so either the deployment never really succeeds even though it says it does, or when triggering the function, the credentials aren't found so it falls back to the cached function.
It seems like this bug has been submitted already, but not resolved: googleapis/google-auth-library-nodejs#320
from firebase-functions.
I renamed my function, then when doing "firebase deploy" I selected "yes" to delete the old one. That got the changes applied
from firebase-functions.
I had the same problem. I know exactly how my package.json
file got out of sync with my project. I added a second root folder to my project so it stopped building my single root folder directly into lib/
and instead started building it in the subfolder. Once I updated package.json
with the new path to index.js
everything was working once again.
from firebase-functions.
@Enricopv thank you, this issue is still a thing
from firebase-functions.
It still a thing. A way to make the changed applied is to run: 'npm start' in the functions folder. It start compilation in watch mode, then if i deploy the last update are deployed.
I don't know where, but it fell like a configuration file miss the instruction to compile before deploying.
from firebase-functions.
Related Issues (20)
- Inconsistend behaviour of defineList in deploy/emulator HOT 4
- TypeError: Cannot read properties of null (reading 'seconds') HOT 15
- Firebase Functions Encoding Failure for Self-Referencing Objects Leads to Maximum call stack size exceeded HOT 15
- Function execution took 58984 ms, finished with status: 'timeout' HOT 2
- [Firestore] Error: 4 DEADLINE_EXCEEDED: Deadline exceeded HOT 1
- HTTPS Request returns CORS errors even with the domain added as allowed origin HOT 4
- How to deploy function with latest secrets at RUNTIME? HOT 2
- DocumentOptions do not allow parameterized configuration values HOT 2
- Various Firebase functions started reporting crash: Maximum call stack size exceeded HOT 10
- regression with firebase-functions-test wrapping a v1 scheduled function HOT 2
- Please move `node-fetch` as a `devDependency` HOT 1
- `getDownloadURL` function fails in emulator mode if storage rules are not allowed HOT 3
- Consider exporting `SecretParam` type HOT 3
- CORS error when calling v2 functions using onCall HOT 3
- CallableOptions doesn't accept BooleanParam which is accepted by HttpsOptions HOT 2
- Structured logging error context not being serialized HOT 3
- Don't verify auth token on public endpoints HOT 5
- Firebase Blocking Auth Functions Run Incorrectly on Failed Signup HOT 2
- Python: Documentation says "from firebase_functions.core import init", however this library doesn't exist at all. Where is it? HOT 1
- Module '"firebase-functions/v1"' has no exported member 'onInit'. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-functions.