heydryft / tlsclient.js

An axios based wrapper for bogdanfinn/tls-client based on ffi-rs for unparalleled performance and usability.
28 stars 9 forks source link

Crash if no response headers #8

Open nxomi opened 7 months ago

nxomi commented 7 months ago

using the tls client on a lot of requests, sometimes it will randomly crash throing this error:

repo\node_modules\@dryft\tlsclient\lib\helpers\adapter.js:125 Object.keys(resJSON.headers).forEach((key) => { ^

TypeError: Cannot convert undefined or null to object at Function.keys () at C:\Users\naomi\Desktop\core-tech\node_modules\@dryft\tlsclient\lib\helpers\adapter.js:125:20 at Generator.next () at fulfilled (C:\Users\naomi\Desktop\core-tech\node_modules\@dryft\tlsclient\lib\helpers\adapter.js:5:58)

Node.js v21.6.0

so i tried logging the response of that failing request adding this on line 124: if (!resJSON.headers) console.log(resJSON);

here is what i got right before it crashed again: { id: 'e1b3ba83-6a72-47d0-b7b2-920bc8224fd8', body: 'failed to do request: Post "https://url.com/api/": read tcp [home ip here]:[port]->[other ip here]:[port]: wsarecv: Une connexion existante a dû être fermée par l’hôte distant.', cookies: null, headers: null, sessionId: '1706887108469', status: 0, target: '', usedProtocol: '' }

i think the module just doesn't handle when a request fails and doesnt return any headers which results in a crash