Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

516
Views
FirebaseError: [code=invalid-argument]: Function setDoc() called with invalid data

I am using Firebase SDK's within Node-red (as specified in NPM docs they can be used for IoT devices with NODE.js).

  • I can use all of the CRUD methods with Firebase RealtimeDatabase.
  • With Firebase Firestore I can only use READ and DELETE functionality.
  • SET and UPDATE results in weird errors that I couldn't find answers anywhere on the internet.

I am importing Firebase SDK's through require() inside settiings.js and functionGlobalContext so I can access them in Node-red functions:

functionGlobalContext: {
    firebase: require('firebase/app'),
    firebaseDatabase: require('firebase/database'),
    firebaseFirestore: require('firebase/firestore'),
    // os:require('os'),
    // jfive:require("johnny-five"),
    // j5board:require("johnny-five").Board({repl:false})
},

First I initialize my whole Firebase project with this code (and everything initializes fine without errors):

//Load data from Global contexta
const firebase = global.get('firebase');
const firebaseDatabase = global.get('firebaseDatabase');
const firebaseFirestore = global.get('firebaseFirestore');


const firebaseConfig = {
     //my Firebase credentials
};

//Set up Firebase
const app = firebase.initializeApp(firebaseConfig);
const database = firebaseDatabase.getDatabase();
const firestore = firebaseFirestore.getFirestore();

//Save the database reference to Global context
global.set('app', app);
global.set('database', database);
global.set('firestore', firestore);

And here I am trying basic SET operation with Firestore:

const ft = global.get('firebaseFirestore');
const firestore = global.get('firestore');

const frankDocRef = ft.doc(firestore, "users", "frank");
await ft.setDoc(frankDocRef, {
    name: "Frank",
    age: 12
});

Unfortunately even though this code is ctrl+c ctrl+v from Firestore docs I get this error:

"FirebaseError: [code=invalid-argument]: Function setDoc() called with invalid data. Data must be an object, but it was: a custom Object object (found in document users/frank)"
  • When I use the same code inside a web app everything works fine.
  • There has to be something going on under the hood with Node-red
  • I tried creating the object using various methods and all of them resulted in the same error.

Does anybody have any idea what could be going wrong here?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!