https://github.com/ThomasKientz/nuxt-firestore-repro
npm install
npm run dev
navigate to localhost:3000
See the error message in the console
Firebase can execute and update without any errors.
Happens only on server-side: Firebase rejects the update as it looks like a "custom object" is being passed, though object was created as object literal.
Possibly Nuxt is modifying or proxying the creation of new objects.
Full error message:
FirebaseError: Function DocumentReference.update() called with invalid data. Data must be an object, but it was: a custom Object object
hi @sunyatasattva , i've just met the similar bug, but instead in nuxtServerInit
.
Then i dived into source to debug, i found that the Object from data was really an custom object, but i don't know where it's was customed.
I searched for the bug on google and there is a bug that may be the same kind of ours. Here: https://github.com/nuxt/nuxt.js/issues/5178
Then i tried add runInNewContext: false
to nuxt.config.js
file, it was work perfectly!!!
I did know that the core of Nuxt using vue server renderer module, and i searched on Nuxt document and Vue server renderer document, there are serveral info about runInNewContext
option.
Here https://nuxtjs.org/guide/release-notes#v2.4.0 and here https://ssr.vuejs.org/api/#runinnewcontext
At the end, i knew that the runInNewContext
is used only in dev mode for some reason. So everything work fine either setting runInNewContext
to false
or running on production mode
Thank you @quocduan I'll try and see if it solves my problem!
Thank you so much @quocduan. You saved a lot of my time!
In my case, the below code which simply follows the firestore documentation does not work on my local when it runs in a Vuex action via fetch in a page with development mode (NODE_ENV=development
) as Nuxt.js universal
(SSR) mode.
db.collection("users").doc(uid).set({ name: "test user" });
I just added the following config to nuxt.config.js
and restarted my nuxt server. Then, it works perfectly!
render: {
bundleRenderer: {
runInNewContext: false
}
},
Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:
Issues that are labeled as pending
will not be automatically marked as stale.
Most helpful comment
hi @sunyatasattva , i've just met the similar bug, but instead in
nuxtServerInit
.Then i dived into source to debug, i found that the Object from data was really an custom object, but i don't know where it's was customed.
I searched for the bug on google and there is a bug that may be the same kind of ours. Here: https://github.com/nuxt/nuxt.js/issues/5178
Then i tried add
runInNewContext: false
tonuxt.config.js
file, it was work perfectly!!!I did know that the core of Nuxt using vue server renderer module, and i searched on Nuxt document and Vue server renderer document, there are serveral info about
runInNewContext
option.Here https://nuxtjs.org/guide/release-notes#v2.4.0 and here https://ssr.vuejs.org/api/#runinnewcontext
At the end, i knew that the
runInNewContext
is used only in dev mode for some reason. So everything work fine either settingrunInNewContext
tofalse
or running on production mode