OpenAI nodeJS library stopped working since last deploy about an hour ago

Our website relies heavily on OpenAI's Node.js library, since an hour ago, it seems there is a new constraint: (error) Error: Dynamic require of "node:util" is not supported. Is the only choice to rewrite everything using fetch();? Thank you, Maurice
8 Replies
akazwz
akazwz•5mo ago
are you add compatibility_flags = ["nodejs_compat"] in wrangler.toml?
mauricescheff
mauricescheffOP•5mo ago
I'm using wrangler pages deploy so I don't have access to wrangler.toml Any other way I can enable nodejs_compat? I see that it works with: npx wrangler pages dev [<DIRECTORY>] --compatibility-flags="nodejs_compat" but I can't do wrangler pages deploy --compatibility-flags="nodejs_compat" It was working without the flag though, until today...
akazwz
akazwz•5mo ago
the pages now support wrangler config
akazwz
akazwz•5mo ago
Cloudflare Docs
Configuration · Cloudflare Pages docs
If your project contains an existing wrangler.toml file that you previously used for local development, make sure you verify that it matches your …
mauricescheff
mauricescheffOP•5mo ago
ok... I downloaded my wrangler.toml and then I realized the nodejs_compatibility flag was already there, I redeployed with wrangler.toml and the nodejs_compatibility flag and I'm still getting this error when I import the OpenAI NodeJs library: (error) Error: Dynamic require of "node:util" is not supported
akazwz
akazwz•5mo ago
i create a simple completions using openai lib. it works for me even not need the compatibility_flags
mauricescheff
mauricescheffOP•5mo ago
Thanks! I'm going to look into it again... and also try with simple example to see how to reproduce it, and if not it's maybe something else... Thank you so much @akazwz ! I figured it out... So I was importing a function from a barrel file and one of the other functions was also being imported (I'm not sure exactly how that works underneath) and the other function was importing using a heavy library. I removed the import and now it works! 🎉
akazwz
akazwz•5mo ago
🎉
Want results from more Discord servers?
Add your server