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

Error devalue.dist:devalue.umd in walk error - Cannot stringify arbitrary non-POJOs #4053

Closed
simllll opened this issue Oct 4, 2018 · 3 comments

Comments

@simllll
Copy link

simllll commented Oct 4, 2018

Version

v2.1.0

Reproduction link

[http://not able to extract the issue](http://not able to extract the issue)

Steps to reproduce

I have a express app that calls nuxt.renderRoute for speicfic routes. Somehow, I wasn't able to track it down, I get the following error for logged in users:
Error: Cannot stringify arbitrary non-POJOs
/var/app/current/node_modules/devalue/dist/devalue.umd.js in walk at line 44:31
/var/app/current/node_modules/devalue/dist/devalue.umd.js in null. at line 49:72
Array.forEach
/var/app/current/node_modules/devalue/dist/devalue.umd.js in walk at line 49:40
/var/app/current/node_modules/devalue/dist/devalue.umd.js in null. at line 49:72
Array.forEach
/var/app/current/node_modules/devalue/dist/devalue.umd.js in walk at line 49:40
/var/app/current/node_modules/devalue/dist/devalue.umd.js in null. at line 49:72
Array.forEach
/var/app/current/node_modules/devalue/dist/devalue.umd.js in walk at line 49:40
/var/app/current/node_modules/devalue/dist/devalue.umd.js in null. at line 49:72
Array.forEach
/var/app/current/node_modules/devalue/dist/devalue.umd.js in walk at line 49:40
/var/app/current/node_modules/devalue/dist/devalue.umd.js in devalue at line 53:5
/var/app/current/node_modules/nuxt/lib/core/renderer.js in Renderer.renderRoute at line 364:50

This issue first occured in nuxt 2, and the initial line that triggers it is the following one in renderRoute:
const serializedSession = window.__NUXT__=${devalue(context.nuxt)};

as far as I understand that means that in context.nuxt is a variable that has function in it? But why? Can we ignore the function? Or how can I get rid of it?

What is expected ?

Should render all routes, even if context.nuxt (what is it actually?), has a function in it

What is actually happening?

Error: Cannot stringify arbitrary non-POJOs

This bug report is available on Nuxt community (#c7909)
@ghost ghost added the cmty:bug-report label Oct 4, 2018
@simllll
Copy link
Author

simllll commented Oct 4, 2018

Indeed I just found out that under some circumstances req.session.flash is set, by the "flash"-express middleware. https://github.com/expressjs/flash

This middleware puts a function into the session. I can imagine there are some other usecases like this too (even though I would agree that this session middleware is not a very nice one).

I suggest that serializedSessino should not crash, even when there is a functino in it. It should just strip all elements away which it can not serialize... (and put a warning to the console?).

@ghost ghost closed this as completed Oct 4, 2018
@ghost
Copy link

ghost commented Oct 4, 2018

This bug-report has been cancelled by @aldarund.

dupe of #4026
PR with fix #4046

@lock
Copy link

lock bot commented Nov 3, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 3, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants