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 not supported in workerd #3053

Open
marzcreatives opened this issue Nov 2, 2024 · 1 comment
Open

WeakRef not supported in workerd #3053

marzcreatives opened this issue Nov 2, 2024 · 1 comment
Labels
feature request Request for Workers team to add a feature

Comments

@marzcreatives
Copy link

Which Cloudflare product(s) does this pertain to?

Workers Runtime, Wrangler

What version(s) of the tool(s) are you using?

3.84.1 [Wrangler]

What version of Node are you using?

20

What operating system and version are you using?

Mac Sequoia

Describe the Bug

It should build and deploy to CloudFlare but it keeps erring saying WeakRef is not supported.
But WeakRef is being used by discord.js dependency in node_modules so there isn't anything I can do.
What's a work around?

package.json

{
  "name": "tqihelperbot",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "wrangler dev",
    "deploy": "wrangler deploy"
  },
  "dependencies": {
    "discord-interactions": "^4.1.0",
    "discord.js": "^14.16.3",
    "wrangler": "^3.84.1"
  },
  "packageManager": "[email protected]",
  "devDependencies": {
    "buffer": "^6.0.3"
  }
}

wrangler.toml

main = "src/index.js"

compatibility_flags = ["nodejs_compat"]
compatibility_date = "2024-10-04"

Please provide a link to a minimal reproduction

https://github.com/marzcreatives/tqiHelperBot

Please provide any relevant error logs

⛅️ wrangler 3.84.1

[wrangler:inf] Ready on http://localhost:8787
⎔ Starting local server...
✘ [ERROR] service core:user:tqihelperbot: Uncaught ReferenceError: WeakRef is not defined

at null.<anonymous> (index.js:33089:16) in module2.exports
at null.<anonymous> (index.js:33107:87) in node_modules/undici/lib/web/fetch/request.js
at null.<anonymous> (index.js:30:50) in __require2
at null.<anonymous> (index.js:33820:47) in node_modules/undici/lib/web/fetch/index.js
at null.<anonymous> (index.js:30:50) in __require2
at null.<anonymous> (index.js:39554:21) in node_modules/undici/index.js
at null.<anonymous> (index.js:30:50) in __require2
at null.<anonymous> (index.js:42327:29) in node_modules/discord.js/src/util/Util.js
at null.<anonymous> (index.js:30:50) in __require2
at null.<anonymous> (index.js:42648:23) in node_modules/discord.js/src/client/BaseClient.js

✘ [ERROR] The Workers runtime failed to start. There is likely additional logging output above.

@marzcreatives marzcreatives added the bug Something isn't working label Nov 2, 2024
@penalosa penalosa transferred this issue from cloudflare/workers-sdk Nov 4, 2024
@penalosa penalosa changed the title 🐛 BUG: WeakRef not supported in workerd Nov 4, 2024
@penalosa penalosa removed this from workers-sdk Nov 4, 2024
@jasnell
Copy link
Member

jasnell commented Nov 5, 2024

I'll mark this as a feature request. Workers intentionally disables use of WeakRef and FinalizationRegistry in order to limit observability of GC, and the nondeterminism it brings, for a number of reasons. I believe WeakRef would likely be somewhat safer to enable than FinalizationRegistry but they are used so frequently together that it might actually cause more issues to enable one but not the other. We'll need to carefully consider this.

@jasnell jasnell added feature request Request for Workers team to add a feature and removed bug Something isn't working labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for Workers team to add a feature
Projects
None yet
Development

No branches or pull requests

2 participants