statsig-io / node-js-server-sdk

Statsig's SDK for server-side Node.js applications.
ISC License
20 stars 15 forks source link

Release 5.7.1 not compatible with next edge runtime #31

Closed simonlovesyou closed 1 year ago

simonlovesyou commented 1 year ago

We're using statsig in next.js middleware to initialize & close statsig sessions & check some feature gates, but we're unable to update statsig-node to release 5.7.1 due to nextjs build errors.

build: Failed to compile.
build: 
build: ../node_modules/js-sha256/src/sha256.js
build: Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
build: Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
build: 
build: Import trace for requested module:
build: ../node_modules/js-sha256/src/sha256.js
build: ../node_modules/statsig-node/dist/Evaluator.js
build: ../node_modules/statsig-node/dist/StatsigServer.js
build: ../node_modules/statsig-node/dist/index.js
build: ./src/utils/statsigUtils.ts

Seems like the new dependency js-sha256 that was added in #30 uses eval .

Please LMK if you want a reproducible example!

Reference

joe-statsig commented 1 year ago

Thanks for the report @simonlovesyou, we'll replace the library with another one compatible at the edge

joe-statsig commented 1 year ago

@simonlovesyou 5.7.2 should be compatible with the edge. Sorry for the inconvenience here.