Next.js Discord

Discord Forum

Production build breaks EventEmitter

Unanswered
Cuvier’s Dwarf Caiman posted this in #help-forum
Open in Discord
Cuvier’s Dwarf CaimanOP
I'm using ldapjs inside of NextJS 14 and a production build breaks the client.search() function which is a nodejs EventEmitter implementation. The search function fires off and then listens for events; in development mode the "searchEntry" event fires as expected when the ldap server returns results, but in production mode it does not.

I have confirmed using Wireshark that in both the dev server as well as production server the ldap search is returning results as expected; however, something is keeping the production server from noticing/processing the results; it just hangs there until the timeout function fires.

Here is my code:
https://gist.github.com/Tesin/a9aeb11710c54c008622583087b89c19

I am authenticating against the ldap server using a Service Account which will then let me execute a search for the user and retrieve the full DN.

Here is the reference documentation for client.search():
https://ldapjs.org/client.html#search

I've suspected this to be a caching issue but i've tried everything I know to disable caching using route segment config all over this project.

Halp, please 😦

6 Replies

Toyger
are you running production version on vercel? it can have runtime limitations
Cuvier’s Dwarf CaimanOP
In my VSCode terminal (or any terminal on my laptop), just switching from "npm run dev" to "npm run build" and "npm start" triggers this.
Vercel is not in play.
Cuvier’s Dwarf CaimanOP
That bug is why I have a setTimeout in the end event to delay its execution. I can completely remove the end event and the behavior is the same unfortunately.
searchEntry never fires despite receiving the packets back from the ldap server.