vwo-node-sdk icon indicating copy to clipboard operation
vwo-node-sdk copied to clipboard

On integrating with server side is causing crashing node application

Open pgaurav9 opened this issue 3 years ago • 7 comments

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.

pgaurav9 avatar Feb 27 '22 17:02 pgaurav9

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

softvar avatar Feb 28 '22 07:02 softvar

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!

pgaurav9 avatar Mar 01 '22 14:03 pgaurav9

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.

softvar avatar Mar 15 '22 11:03 softvar

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.

nickdandakis avatar Jun 10 '22 18:06 nickdandakis

we have the same issue

iamstarkov avatar Dec 07 '22 14:12 iamstarkov

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

iamstarkov avatar Dec 07 '22 14:12 iamstarkov

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

lytvynenko avatar Dec 28 '22 04:12 lytvynenko