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 When Using @nuxt/pinia v0.6.0+ with Nuxt Apollo Composables #2837

Closed
carlosgrossi opened this issue Nov 18, 2024 · 1 comment
Closed

Comments

@carlosgrossi
Copy link

Reproduction

https://stackblitz.com/edit/nuxt-starter-5sgmex

Steps to reproduce the bug

As soon as the server is up, on the first SSR run the "ERROR [nuxt] [request error] [unhandled] [500] obj.hasOwnProperty is not a function" will appear in the terminal and the page will display "500 internal server error"

Expected behavior

App.vue page should load with sample data retrieved from https://spacex-production.up.railway.app

Actual behavior

The browser displays an "Error 500 internal server error" message:

Screenshot 2024-11-18 at 17 14 31

The terminal shows a message "ERROR [nuxt] [request error] [unhandled] [500] obj.hasOwnProperty is not a function"

Screenshot 2024-11-18 at 17 14 58

Additional information

The error occurs when @nuxt/pinia version 0.6.0 upwards is used in conjunction with Nuxt Apollo, when one of its composables is used in <script setup> the error occurs right after receiving the queried data from the server.

I could trace the error back to the definePayloadPlugin [packages/nuxt/src/runtime/payload-plugin.ts]. This plugin calls the shouldHydrate function [packages/pinia/src/store.ts]. When used in conjunction with Nuxt Apollo’s composables, such as useAsyncQuery, the result of the query is received by the payload reducer and passed to the shouldHydrate function. ShouldHydrate then calls hasOwnProperty on the object received and the error is triggered and handled by Nuxt downstream.

Screenshot 2024-11-18 at 17 34 09

@posva
Copy link
Member

posva commented Nov 18, 2024

Duplicate of #2822

@posva posva marked this as a duplicate of #2822 Nov 18, 2024
@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@vuejs vuejs locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants