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

WeakRef is not supported in Cloudflare Workers #1949

Open
daniandl opened this issue Nov 4, 2024 · 1 comment
Open

WeakRef is not supported in Cloudflare Workers #1949

daniandl opened this issue Nov 4, 2024 · 1 comment
Labels
question Further information is requested

Comments

@daniandl
Copy link

daniandl commented Nov 4, 2024

Environment

playground

Reproduction

https://stackblitz.com/edit/nuxt-starter-wgz5jk?file=app.vue

Wrangler probably won't work inside the playground, you will need to clone locally.
Run NITRO_PRESET=cloudflare_pages pnpm run build to build the server.
Then run npx wrangler pages dev dist/

The page will have an error about WeakRef not being defined.

Describe the bug

WeakRef is not supported in Cloudflare Workers currently.
That makes it impossible to run this plugin with Nuxt SSR.

Additional context

Workaround:
You can polyfill this by making a plugins/weakref-polyfill.server.ts file and adding the contents of https://github.com/jaenster/weakref-pollyfill/blob/master/src/index.js.
Don't forget to add export default defineNuxtPlugin(() => {}) at the end or it will be ignored at build time.

You may consider polyfilling WeakRef in this package, but it is probably out of scope for this library.

I hope that is the last of my issues with this library for a while :)

Logs

No response

@CodeDredd
Copy link
Owner

CodeDredd commented Nov 24, 2024

@daniandl ok...have you tried using this SimpleCache in the config? I think this should solve it.

related: cloudflare/workerd#3053

@CodeDredd CodeDredd added question Further information is requested and removed pending triage labels Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants