Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-side Nuxt modifying plain objects #6480

Closed
sunyatasattva opened this issue Sep 28, 2019 · 4 comments
Closed

Server-side Nuxt modifying plain objects #6480

sunyatasattva opened this issue Sep 28, 2019 · 4 comments

Comments

@sunyatasattva
Copy link

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)
@ghost ghost added the cmty:bug-report label Sep 28, 2019
@quocduan
Copy link

quocduan commented Oct 9, 2019

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: #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

@sunyatasattva
Copy link
Author

Thank you @quocduan I'll try and see if it solves my problem!

@doi-t
Copy link

doi-t commented Oct 26, 2019

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
    }
  },

doi-t added a commit to doi-t/neoshogi that referenced this issue Oct 26, 2019
@stale
Copy link

stale bot commented Nov 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants