launchdarkly / node-server-sdk

LaunchDarkly Server-side SDK for Node
Other
79 stars 65 forks source link

NextJS middleware/edge support? #276

Closed gsheppard closed 1 year ago

gsheppard commented 1 year ago

Describe the bug

When importing the SDK in the middleware of a NextJS application, I get the errors listed below. To be fair, I don't know if this is supposed to be supported or not, but searching for the words "nextjs" and "edge" did not show anything specific.

For context, this is for SSG/ISR pages. The plan was to generate the various versions and rewrite requests based on LaunchDarkly decision.

On Build:

Error: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime

On dev server:

Error: The edge runtime does not support Node.js 'os' module.

To reproduce

SDK version 7.0.1

Language version, developer tools

louis-launchdarkly commented 1 year ago

Hello @gsheppard, I don't know would this https://github.com/launchdarkly/js-core/blob/main/packages/sdk/vercel/README.md work directly for your use case, but the Edge SDKs that we are currently developing are located in the js-core repository going forward. If that SDK doesn't address your use case, can you file the issue there?

gsheppard commented 1 year ago

@louis-launchdarkly Thank you. That does appear to be the package I need, though that it also immediately throwing errors. But I'll log those with that repo. Thank you.

kinyoklion commented 1 year ago

Please note this package is currently pre-release, though should be release within the next couple days.