@discordjs/rest: TypeError: Super expression must either be null or a function
I use
@discordjs/rest (2.6.0) to post to my server once a day. Yesterday, I upgraded my project's dependencies. @vladfrangu/async_event_emitter was updated from 2.4.6 to 2.4.7.
Today, posts fail with TypeError: Super expression must either be null or a function in @vladfrangu/async_event_emitter/node_modules/node-inspect-extracted/dist/inspect.js:2:44522
Anyone else seeing this? Guess I should pin async_event_emitter to 2.4.6?64 Replies
node is 22.16.0, and it's failing both locally and in production (Cloudflare Workers)
full code is
what type is the
DISCORD_CHANNELID?string.
should clarify what is the channel type
overriding the async emitter package to 2.4.6 fixed the issue for me
Duh sorry. It's a forum channel
On phone rn, can investigate further on laptop if that's useful
yes please
I was unable to replicate here are my dependencies
I can't replicate in a fresh repo, will try adding stuff from real codebase until something breaks
yes pls
maybe its even your wrangler config
or at least the stacktrace you're getting
and here is my
package.json in case useful
well that stracktrace is not useful but it sounds like you repro'd?
it shouldn't tho
the inspect module is bundled INTO aee
not a node_modules dep
i haven't time to create a minimal repository that reproduces the erro sorry, but in my actual project I hit the error every time with async_emitter 2.4.7. both in cloudlfare, and localhost
does it trigger solely when you import discordjs/rest
can you test that pls
bc i need to know if its that or when an error event is emitted
i do wonder if wrangler is messing smth up
I also dont understand why your stack trace mentions an internal node_modules when one shouldn't exist
interesting
humor me
does this throw
having said that, maybe js is smart enough to skip the import if REST is unused? (not an expert here)
i wonder if this is just wrangler messing smth up hardcore
yes this throws
fascinating
other random things, probably not useful:
- this is one project in a monorepo that i'm managing with pnpm workspaces. no other projects use discordjs
- to date, 100% of the time something weird has happened, it has been
@sentry/cloudflare's faultcan you override aee with version
2.4.8-1.0 and lmk if it still errors?- i added
"overrides": { "aee": "2.4.8-1.0" }
- deleted node_modules
- ran pnpm install -r
- still errorswell
the module name is not aee
its
@vladfrangu/async_event_emitter😂
one second
still errors
and if you nuke the sentry thing
also can you
ll /home/foo/projects/foo/foo/node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7
ofc adjusted for correct versionno such directory. but
ll node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.8-1.0/ reports node_moduleswhat the everloving fuck
lmk if you want me to undo the override and retry 2.4.7
dare i ask why the everloving fuck
can you show me the package.json with 2.4.7 pls
just checking I'm doing the right thing - I still have your
2.4.8.-1.0 override in place
will undo it now
have removed the override, and ll node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7 now reports node_modules
package.json for project
package.json for root of monorepo
and what package.json
what do you mean? have pasted the project and monorepo package.json's
the package.json in the node_modules folder
/home/foo/projects/foo/foo/node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7/package.json
or w/efull path is
/node_modules/.pnpm/@vladfrangu+async_event_emitter@2.4.7/node_modules/@vladfrangu/async_event_emitter/package.jsonoh and in the nested node_modules is there more than 1 thing?
ie deeper than the path you gave me
ok so the code is fine
atp i feel like its wrangler doing something nasty
or sentry
can you check without sentry
i can look at removing sentry as you said, but it's quite a bit of editing as there's loads of sentry stuff scattered about
for info my
fetch and scheduled handlers are wrapped in export default Sentry.withSentry()what if you import rest without await import
but just
import
whole worker fails to start
what the fuck is wrangler doing
@Jiralite can youuu test out a wrangler setup?
same ver as them?
maybe its the compat date???
or the node flag??
idfk
i have a fresh repo which hits the error
lemme tidy it up and publish it, will be a minute
this does feel like an issue to be reported to cf tho
I can fix it on my end to drop the inspect and go back to how it was but yknow
it must be either compat date or compat flags
compat date
yeah infinitely appreciated that you actually helped us figure it out
haha thanks, no worries! fun saturday night
now the question is
how do we tell cf to fix it :meguFace:
annd will they even fix it
as you can tell, i know very little about pnpm and node_modules etc so sorry if it was a bit slower than it needed to be
yes if i move it today's date, it goes away
BRUH
if you haven't got there already,
2025-05-04 is the last breaking date and 2025-05-05 is the first working dateCloudflare Docs
Compatibility flags
Opt into a specific features of the Workers runtime for your Workers project.
Wtf
Did you just bisect the compat dates
correct. adding the flag but keeping my original compat_date fixes it
Maybe inspect does things with weak refs?
@Matthew hewwo, can you try
@vladfrangu/async_event_emitter@2.4.9-2.0 with your current config without the weak ref flagstill fails, seriously??
yup. this fails:
git clone -b @vladfrangu/async_event_emitter@2.4.9-2.0 git@github.com:catfishing-game/discordjs-async-issue.git && cd discordjs-async-issue && pnpm install && pnpm dev