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

fix: warn for non serializable data instead of Error #4046

Merged
merged 9 commits into from
Oct 11, 2018

Conversation

aldarund
Copy link

@aldarund aldarund commented Oct 3, 2018

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Resolves #4026
Will warn and skip instead of error
nuxt-contrib/devalue#1 related PR in fork

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@aldarund aldarund added the WIP label Oct 3, 2018
@aldarund aldarund self-assigned this Oct 3, 2018
@aldarund aldarund changed the title use @nuxtjs/devalue Warn for non serializable data instead of Error Oct 3, 2018
@galvez
Copy link

galvez commented Oct 3, 2018

@aldarund need to fix the tests.

@aldarund aldarund changed the title Warn for non serializable data instead of Error fix: warn for non serializable data instead of Error Oct 4, 2018
@manniL
Copy link
Member

manniL commented Oct 4, 2018

We should consider adding test sets for the states.

@codecov-io
Copy link

codecov-io commented Oct 4, 2018

Codecov Report

Merging #4046 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #4046   +/-   ##
=======================================
  Coverage   97.24%   97.24%           
=======================================
  Files          18       18           
  Lines        1272     1272           
  Branches      351      351           
=======================================
  Hits         1237     1237           
  Misses         33       33           
  Partials        2        2
Impacted Files Coverage Δ
lib/core/renderer.js 100% <ø> (ø) ⬆️
lib/builder/builder.js 96.41% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 521c377...fb349a9. Read the comment docs.

# Conflicts:
#	package.json
#	packages/nuxt-legacy/package.json
#	yarn.lock
@clarkdo
Copy link
Member

clarkdo commented Oct 11, 2018

The extract-css test has been changed, I think you can just revert it, then we can merge this pr 😎

@aldarund
Copy link
Author

@clarkdo merged latest dev, should be fine now

@clarkdo clarkdo merged commit d35fc8f into nuxt:dev Oct 11, 2018
@clarkdo
Copy link
Member

clarkdo commented Oct 11, 2018

@galvez @manniL Could you help update release note?

@manniL
Copy link
Member

manniL commented Oct 11, 2018

On it ☺️

@benfavre
Copy link

Thanks

@sh
Copy link

sh commented Oct 15, 2018

For me this change still breaks vue-apollo in asyncData. I've attached a snippet that we use in most of our slug-based page components.

export default {
  asyncData: async ({ error, app, params }) => {
    let client = app.apolloProvider.defaultClient
    if (!params.slug) {
      return error({ statusCode: 404, message: "Not found" })
    }

    const { data } = await client.query({
      query: itemBySlugQuery,
      variables: { slug: params.slug },
    })

    if (!data.itemBySlug) {
      return error({ statusCode: 404, message: "Not found" })
    }

    console.log(Object.getOwnPropertySymbols(data.itemBySlug))
    // => logs [ Symbol(id) ]

    return Object.assign({}, { track: data.itemBySlug })
    // doesn't convert the symbol => TypeError: Cannot convert a Symbol value to a string
  },
}
✖ error TypeError: Cannot convert a Symbol value to a string
  at Array.toString (native)
  at walk (/Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:52:85)
  at /Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:55:76
  at Array.forEach (<anonymous>)
  at walk (/Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:55:44)
  at Array.forEach (<anonymous>)
  at walk (/Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:36:27)
  at /Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:55:76
  at Array.forEach (<anonymous>)
  at walk (/Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:55:44)
  at devalue (/Users/sh/dev/deepdrive/frontend/node_modules/@nuxtjs/devalue/dist/devalue.umd.js:60:5)
  at Renderer.renderRoute (/Users/sh/dev/deepdrive/frontend/node_modules/nuxt-edge/dist/nuxt.js:2097:65)
  at process._tickCallback (internal/process/next_tick.js:68:7)

Let me know if you need a reproduction repo to dig deeper or if this issue should be filed against vue-apollo.

@davision
Copy link

davision commented Oct 15, 2018

Same error as before, when using asyncData:

✖ error NuxtServerError: Cannot stringify POJOs with symbolic keys
  at walk (node_modules/devalue/dist/devalue.umd.js:47:31)
  at node_modules/devalue/dist/devalue.umd.js:49:72
  at Array.forEach (<anonymous>)
  at walk (node_modules/devalue/dist/devalue.umd.js:49:40)
  at Array.forEach (<anonymous>)
  at walk (node_modules/devalue/dist/devalue.umd.js:33:27)
  at node_modules/devalue/dist/devalue.umd.js:49:72
  at Array.forEach (<anonymous>)
  at walk (node_modules/devalue/dist/devalue.umd.js:49:40)
  at devalue (node_modules/devalue/dist/devalue.umd.js:53:5)
  at Renderer.renderRoute (node_modules/nuxt/dist/nuxt.js:2042:50)
  at <anonymous>

Am I missing something

@aldarund
Copy link
Author

@davision from your changelog u are using original devalue lib. Are u on nuxt 2.2 ? Delete node modules and lock file and reinstall then.

@aldarund
Copy link
Author

@sh reproduction repo would help

@aldarund
Copy link
Author

@sh actually found a problem, will fix asap

@davision
Copy link

I am on 2.2 yes, also deleted node_modules completely and reinstall. Will check again with new PR!

@manniL
Copy link
Member

manniL commented Oct 15, 2018

@davision Be aware that there was no release yet, so you have to test it "manually".

@sh
Copy link

sh commented Oct 15, 2018

@aldarund awesome, thanks :)

I've pulled your changes from nuxt-contrib/devalue#3 and can confirm it's fixed for me!

@manniL
Copy link
Member

manniL commented Oct 15, 2018

@aldarund I think we should do a minor release 🤔

@aldarund
Copy link
Author

@manniL ye, i planned to do it today :)

@aldarund
Copy link
Author

@sh @davision @manniL i have published updated version of devalue , now on npm

@davision
Copy link

Which version is it? with 1.0.4 there is still the same error.

@manniL
Copy link
Member

manniL commented Oct 23, 2018

@davision There is no 1.0.4 of @nuxtjs/devalue. Only 1.0.1. https://github.com/nuxt-community/devalue

The change is included in Nuxt 2.2.0

@davision
Copy link

I've tried reinstalling everything once again, and finally, it works! Thanks.

@lock
Copy link

lock bot commented Nov 22, 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 22, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error NuxtServerError: Cannot stringify a function
9 participants