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

[BUG] Uncaught Error: 'cookies' called outside request scope after migration to Vite #2818

Open
1 task done
AtelyPham opened this issue Feb 12, 2025 · 0 comments · May be fixed by #2822
Open
1 task done

[BUG] Uncaught Error: 'cookies' called outside request scope after migration to Vite #2818

AtelyPham opened this issue Feb 12, 2025 · 0 comments · May be fixed by #2822
Assignees
Labels
app: tangle-dapp type: bug 🪲 Something isn't working

Comments

@AtelyPham
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When toggling the sidebar component, the following error appears in the console:

Uncaught Error: cookies was called outside a request scope.
Read more: https://nextjs.org/docs/messages...
at setSidebarCookieOnToggle

This error occurs because the application is still using Next.js cookie utilities (setSidebarCookieOnToggle from @webb-tools/webb-ui-components/next-utils) after migrating to Vite without SSR.

Expected Behavior

The sidebar toggle state should persist without throwing errors, using a client-side storage solution compatible with Vite/React applications (e.g., localStorage or a non-Next.js cookie solution).

Steps To Reproduce

  1. Open the application running on Vite
  2. Open the developer console
  3. Click on the sidebar toggle button
  4. Observe the error in the console

Screenshot

Image

Anything else?

The error is occurring in apps/tangle-dapp/src/components/Sidebar/Sidebar.tsx where we're using setSidebarCookieOnToggle from Next.js utilities despite having migrated to Vite.

import { setSidebarCookieOnToggle } from '@webb-tools/webb-ui-components/next-utils';

// ...

<SideBarCmp
  {...sidebarProps}
  pathnameOrHash={location.pathname}
  className="hidden lg:block !z-0"
  isExpandedByDefault={isExpandedByDefault}
  onSideBarToggle={setSidebarCookieOnToggle}
/>

This needs to be updated to use a Vite-compatible solution for persisting the sidebar state.

@AtelyPham AtelyPham added app: tangle-dapp type: bug 🪲 Something isn't working labels Feb 12, 2025
@github-project-automation github-project-automation bot moved this to Not Started 🕧 in Webb Universe Feb 12, 2025
@AtelyPham AtelyPham moved this from Not Started 🕧 to Planning 🗺️ in Webb Universe Feb 12, 2025
@AtelyPham AtelyPham moved this from Planning 🗺️ to Not Started 🕧 in Webb Universe Feb 12, 2025
@devpavan04 devpavan04 moved this from Not Started 🕧 to Building 🏗️ in Webb Universe Feb 13, 2025
@devpavan04 devpavan04 linked a pull request Feb 13, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app: tangle-dapp type: bug 🪲 Something isn't working
Projects
Status: Building 🏗️
Development

Successfully merging a pull request may close this issue.

2 participants