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

Setting store values in succession breaks cookie persistence ?? #259

Closed
4 tasks done
fosterdouglas opened this issue Nov 15, 2023 · 3 comments
Closed
4 tasks done
Labels
🔍️ pending triage This issue needs to be looked into

Comments

@fosterdouglas
Copy link

fosterdouglas commented Nov 15, 2023

Describe the bug

I've come across some strange behavior and have spent many hours trying to debug. At the end, it seems as though setting multiple values in a store in succession causes persistence to fail with cookies?

In this example, any combination of 2 of these lines works properly, but using 3 or more (of any combination), it results in the values of all of them in the cookie being null.
Screenshot 2023-11-14 at 18 28 15

The objects I'm setting are relatively small in kb size.

This is obviously absurd and seems like unlikely behavior, but I've really tried everything to fix it. I'm setting the values from a composable, but I've tried it directly in a component as well.

I'm using 3.2.0, and 2.1.7 of Pinia, with no custom options in nuxt.config, and a basic Setup store:

export const useContextStore = defineStore(
  'context-store',
  () => {
    // STATES //
    const companyContext = ref<Company>(null)
    const userContext = ref<User>(null)
    const productContext = ref<Product>(null)
    const userPhoneContext = ref<UserPhone>(null)

    const authStatusMessage = ref('')
    const appNavigationExpanded = ref(false)

    // ACTIONS //
    function $reset() {
      companyContext.value = null
      userContext.value = null
      productContext.value = null
      userPhoneContext.value = null

      authStatusMessage.value = ''
      appNavigationExpanded.value = false
    }

    return {
      companyContext,
      userContext,
      productContext,
      userPhoneContext,
      authStatusMessage,
      appNavigationExpanded,
      $reset,
    }
  },
  {
    persist: true,
  }
)

If anyone has any ideas of why this might be happening or how I can approach debugging, let me know! Thank you!

Reproduction

System Info

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M1
    Memory: 1.19 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.7.0 - ~/.nvm/versions/node/v20.7.0/bin/node
    npm: 10.1.0 - ~/.nvm/versions/node/v20.7.0/bin/npm
  Browsers:
    Chrome: 119.0.6045.123
    Safari: 17.0

Used Package Manager

npm

Validations

@fosterdouglas fosterdouglas added the 🔍️ pending triage This issue needs to be looked into label Nov 15, 2023
@prazdevs
Copy link
Owner

this seems oddly related to #52 at first glance 🤔

@MikkelSVDK
Copy link

MikkelSVDK commented Dec 22, 2023

I encountered a similar issue, and it turned out I was exceeding the cookie size limit of 4096 bytes. Could this be the case for you too? Check the data size stored in the cookie.

@fosterdouglas
Copy link
Author

I encountered a similar issue, and it turned out I was exceeding the cookie size limit of 4096 bytes. Could this be the case for you too? Check the data size stored in the cookie.

That was exactly my issue as well! I forgot to revisit this to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍️ pending triage This issue needs to be looked into
Projects
None yet
Development

No branches or pull requests

3 participants