wingify / vwo-node-sdk

VWO Node SDK for server-side testing
https://developers.vwo.com/docs/fullstack-overview
Apache License 2.0
24 stars 9 forks source link

On integrating with server side is causing crashing node application #35

Open pgaurav9 opened 2 years ago

pgaurav9 commented 2 years ago

While integrating the vwo-node-sdk library on the server-side of an existing SSR react application is crashing the whole application. Following is the exception that I am receiving: `events.js:377 throw er; // Unhandled 'error' event ^

Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) Emitted 'error' event on ClientRequest instance at: at TLSSocket.socketErrorListener (_http_client.js:475:9) at TLSSocket.emit (events.js:400:28) at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:82:21) { errno: -54, code: 'ECONNRESET', syscall: 'read' } error Command failed with exit code 1.`

However, the documentation provided here, mentioned about following best practices, which itself is a generic statement. Kindly help here. Thanks! Please follow the best practices to ensure that your app is prevented from crashing.

softvar commented 2 years ago

Hey @pgaurav9 ,

Could you please let us know the following so that we can debug this:

  1. Node version being used
  2. NPM/yarn version being used
  3. VWO SDK version
  4. Is it an Express-based framework or any other?
  5. When does the error appear? Is it when the app is launched or when any API is invoked?

Thanks

pgaurav9 commented 2 years ago

Hi @softvar ,

I am using the following:

  1. Node version: 14.18.1
  2. Yarn version: 1.22.17
  3. VWO SDK version: 1.32.3
  4. Yes we are using Express(version 4.17.1)
  5. Error appears after any of the API invoked using VWO client. Example when the application requests settingsFile(using settingsFile method) or activate(using activate method), immediately after executing everything it gets crashed all of sudden. I tried to put logs, and I am getting responses from the above-mentioned functions. But somehow it keeps crashing.

Let me know if further information is required. Thanks!

softvar commented 2 years ago

Hi @pgaurav9 ,

After debugging, it seems to be an issue with Node 14.x and 16.x versions. This is something related to how async-await works internally. Our SDK does not use sockets, instead only https module for sending any async network call.

Please try without async-await syntax and let us know if it's resolved for you.

In the meantime, we are still figuring out what is causing this issue in different latest node.js versions.

nickdandakis commented 2 years ago

hey @softvar, we've been seeing this in our application and I attempted to get a minimal repro setup for y'all to debug here: https://github.com/nickdandakis/vwo-node-nextjs-ssr

of course, as these things go, this minimal repro doesn't actually produce the ECONNRESET issue reliably. we've also found that the local server doesn't actually crash (maybe nextjs is handling this gracefully), and the deployed environment (on Render or AWS) doesn't actually produce this ECONNRESET

I tried using node v14, v16 (what we use), and v18 (app doesn't even run on v18 yet), and no luck in getting a consistent repro.

I'll keep the repo up in case it's helpful for anyone else trying to get the VWO node SDK to work against SSR Nextjs, which I imagine is becoming more and more popular.

iamstarkov commented 1 year ago

we have the same issue

iamstarkov commented 1 year ago

Node version: 18.12.0 Yarn version: 1.22.17 VWO-node-SDK version: 1.41.0 Yes we are using Express(version 4.17.1) Errors roll once we run vwo.launch

lytvynenko commented 1 year ago

this PR fixes (kinda) the issue - https://github.com/wingify/vwo-node-sdk/pull/44. At least it doesn't crash the server anymore.