Nuxt.js: Server-side Nuxt modifying plain objects

Created on 29 Sep 2019  路  4Comments  路  Source: nuxt/nuxt.js

Version

2.8.1

Reproduction link

https://github.com/ThomasKientz/nuxt-firestore-repro

Steps to reproduce

  1. npm install
  2. npm run dev
  3. navigate to localhost:3000
  4. See the error message in the console

What is expected ?

Firebase can execute and update without any errors.

What is actually happening?

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.

Additional comments?

Full error message:

FirebaseError: Function DocumentReference.update() called with invalid data. Data must be an object, but it was: a custom Object object

This bug report is available on Nuxt community (#c9832)
bug-report 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 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

All 4 comments

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:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

danieloprado picture danieloprado  路  3Comments

gary149 picture gary149  路  3Comments

maicong picture maicong  路  3Comments