statsig-io / node-js-server-sdk

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

Node 12.x support #6

Closed youminkim closed 3 years ago

youminkim commented 3 years ago

My Vercel's default node version was 12.x so I got following error. I am upgrading to 14.x now but reporting here just FYI

[GET] /_next/data/zCOy1dluHO0Tg6UTUg7Ez/es/s/6587256789.json
00:46:31:24
2021-06-12T16:46:32.737Z    7729138c-4c89-40a9-b162-8bca86ab1aea    ERROR   /var/task/node_modules/statsig-node/src/index.js:79
        const value = gate?.value ?? false;
                           ^
SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.5047 (/var/task/.next/server/pages/s/[phone].js:203:18)
    at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:42)
    at AppGetStaticPropsWrapper (/var/task/.next/server/chunks/8005.js:610:19)
RequestId: 7729138c-4c89-40a9-b162-8bca86ab1aea Error: Runtime exited with error: exit status 1
Runtime.ExitError
jkw-statsig commented 3 years ago

@youminkim apologize this flew under our radar. Were you able to find a workaround for the issue?

Looks like the issue is that you are using our node server SDK for client rendering logic, and webpack was not able compile the "?." and "??" syntax. For client side logic we recommend using our react SDK, or js client SDK, which shouldn't have this issue as they are designed to work with webpack.