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

[🐞] usePopover with Cloudflare adapter fails to respond/causes qwik error 20 #837

Closed
osdiab opened this issue Jun 11, 2024 · 7 comments
Closed
Labels
STATUS-1: needs triage This doesn't seem right TYPE: bug Something isn't working

Comments

@osdiab
Copy link

osdiab commented Jun 11, 2024

Which package is affected?

Headless Kit

Describe the bug

I tried deploying a small Qwik website with a manual usePopover() in it, and it worked locally; but when deploying to Cloudflare Pages, I got this error on the production logs:

  `Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.\nSee https://qwik.dev/docs/components/tasks/#use-method-rules`

From the stack trace looks like it's something inside of the usePopover() hook. That said I am pretty new to Qwik so maybe I'm holding it wrong.

EDIT

I tried to make a minimal reproduction, but then instead now I'm seeing that the example nearly straight copy-pasted from the usePopover() example on the Qwik UI website just doesn't seem to call the handler at all (but something outside of the Popover.Root works fine):

Repro: https://github.com/osdiab/repro-qwik-ui-popover-cloudflare-fail

Result on Cloudflare Pages: https://5bc62893.repro-qwik-ui-popover-cloudflare-fail.pages.dev

  • first button should toggle a popover and log to console, it doesn't
  • second button logs to console outside of Popover root, it's fine

Reproduction

https://github.com/osdiab/personal-website/blob/93179b5ae60e1c23fc821f75541b5b4a7778e332/apps/web-app/src/components/tooltip.tsx#L48

Steps to reproduce

Locally no error, but when I deployed this on Cloudflare Pages then try to access the page, it returns a 500 and I get the error.

  • make a qwik app
  • add cloudflare adapter
  • make a component that uses usePopover() in it
  • see it works locally
  • deploy to Cloudflare
  • set NODE_VERSION env var
  • set node_compat compat flag
  • see that it doesn't respond/in the case of my personal website, it errors

I tried to remove all the other use*, event handlers, etc from my personal website Tooltip example, but it crashes until I comment out the usePopover() altogether.

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 292.73 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.7.3 - ~/.asdf/installs/nodejs/21.7.3/bin/node
    npm: 10.5.0 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.0.4 - ~/.asdf/shims/pnpm
    Watchman: 2024.05.06.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 125.0.6422.142
    Edge: 125.0.2535.92
    Safari: 17.5
  npmPackages:
    @builder.io/qwik: ^1.5.5 => 1.5.5
    @builder.io/qwik-city: ^1.5.5 => 1.5.5
    @builder.io/vite-plugin-macro: ~0.0.7 => 0.0.7
    @qwik-ui/headless: ^0.4.4 => 0.4.4
    typescript: 5.4.5 => 5.4.5
    undici: * => 6.13.0
    vite: ^5.2.13 => 5.2.13

Additional Information

Error: Code(20) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L28
    at createAndLogError (functionsWorker-0.5285299984186582.js:4936:52)
    at logErrorAndStop (functionsWorker-0.5285299984186582.js:4927:55)
    at qError (functionsWorker-0.5285299984186582.js:4968:10)
    at useInvokeContext (functionsWorker-0.5285299984186582.js:6327:11)
    at useSequentialScope (functionsWorker-0.5285299984186582.js:5260:16)
    at useConstant (functionsWorker-0.5285299984186582.js:6038:24)
    at useSignal (functionsWorker-0.5285299984186582.js:6041:35)
    at usePopover (functionsWorker-0.5285299984186582.js:11174:32)
    at AsyncFunction.S1 [as resolved] (functionsWorker-0.5285299984186582.js:12808:50)
    at AsyncFunction.ui (functionsWorker-0.5285299984186582.js:2333:19)
@osdiab osdiab added STATUS-1: needs triage This doesn't seem right TYPE: bug Something isn't working labels Jun 11, 2024
@osdiab osdiab changed the title [🐞] popover appears to cause qwik error 20 - [🐞] usePopover with Cloudflare adapter fails to respond/causes qwik error 20 Jun 24, 2024
@osdiab
Copy link
Author

osdiab commented Jun 24, 2024

same thing seems to happen on vercel edge

@thejackshelton
Copy link
Collaborator

Working on this @osdiab 🫡

@thejackshelton
Copy link
Collaborator

thejackshelton commented Jun 28, 2024

@osdiab try @builder.io/qwik and @builder.io/qwik-city w/ the key of dev and see if this fixes your problem. Seems to work for me

@osdiab
Copy link
Author

osdiab commented Jun 30, 2024

@thejackshelton sorry I don’t think I understand what you mean - do you mean the latest dev build of qwik/qwik-city? Thanks!

@thejackshelton-kunaico
Copy link

@thejackshelton sorry I don’t think I understand what you mean - do you mean the latest dev build of qwik/qwik-city? Thanks!

Try Qwik 1.6, as I think this should fix the issue.

@osdiab
Copy link
Author

osdiab commented Jul 2, 2024

Confirmed that it did make the repro repo work, but my personal one is still not OK; debugging further to see if I can figure something out. Thanks,

@osdiab
Copy link
Author

osdiab commented Jul 11, 2024

Qwik 1.7 made this go away.

@osdiab osdiab closed this as completed Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage This doesn't seem right TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants