Giter Club home page Giter Club logo

Comments (15)

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Hey there @WimSuenensDIRACIndustries,

It's kinda hard to diagnose the problem without seeing your code. Can you post the following:

  1. Your Restlet
  2. The Node.JS code you are using
  3. I see you are using nodemon. What configuration do you have it running under?
  4. What version of NSRestlet are you using?
  5. Which version of Netsuite are you using (they are pushing an update which changes restlets a bit currently and it might be related)

I know some parts of the code may be private, so just post the parts you think might be relevant.

Thanks.

from nsrestlet.

WimSuenensDIRACIndustries avatar WimSuenensDIRACIndustries commented on June 12, 2024

Hi Michael,
I can share you these files.
I'm using an node-express server which communicates with NetSuite through your package. This server is providing API's to my frontend which is running Angular. My restlet is just returning json. All my calls are working properly, however from time to time the server crashes with this feedback. 'actual_error' is undefined.
So, there is some issue in the callbacks.
I'm not sure, but it could be an error which occurs when NetSuite is down or unable to reach.
Regards,
Wim

netsuiteRP.js.pdf
requestRP.js.pdf

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Hey Wim, thanks, I'll take a look at those. Also, can you tell me the following:

Are you just using default nodemon from the command line (no arguments added)?

Which version of nsrestlet do you have? (Trying to see if it's an earlier version)

Which version is your Netsuite? (Like 2019.1, 2019.2, etc)

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Also, as a temporary fix, try the following:

  1. Go to nsrestlet inside of your node_modules. Find the nsrestlet.js file.
  2. Change line 531 to the following:

var error_message = error.message || JSON.stringify(error);

Let me know if that works for you.

I'm going to be heading to work soon, so it may be a while before my next response. I'll try to get back to you as soon as I can. Hope your having a good morning
-Michael

from nsrestlet.

WimSuenensDIRACIndustries avatar WimSuenensDIRACIndustries commented on June 12, 2024

I'm using default nodemon, indeed.
nsrestlet version 2.0.1 and NetSuite 2019.2.

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Thanks. Did the fix I posted above work?

from nsrestlet.

WimSuenensDIRACIndustries avatar WimSuenensDIRACIndustries commented on June 12, 2024

I've updated as requested and will test it like this in the next days.
As said, they issue occurs for an unknown reason, so I will see in the coming days if it works out correctly. Thanks for the feedback!

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Thanks! And yeah, please let me know.

Also, just a note, that code would have only been thrown if Netsuite threw an error. So just make sure your Error catching is smooth and you should be good.

I'll also try and push an updated version of the module with this fix sometime soon.

from nsrestlet.

WimSuenensDIRACIndustries avatar WimSuenensDIRACIndustries commented on June 12, 2024

Hello Michael,
FYI: all is working properly. The errors which causes the module to crash were 'ENOTFOUND' and 'ENETDOWN'. I can handle this in my code now.
Thanks.
Kind regards,
Wim

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Hey Wim,
Thanks for the update. I'll close this for now, but if it happens again, please leave another comment and I'll re-open it right up.

Hope you have an awesome Friday!

from nsrestlet.

mritzco avatar mritzco commented on June 12, 2024

Hi,

Same thing happening to me. It only happens once every hundreds of calls, so I'm pretty sure it's a real exception on connection or NetSuite response. Very hard to replicate.

TypeError: Cannot read property 'error' of undefined
at Request._callback (/home/node/io_hubspot/node_modules/nsrestlet/nsrestlet.js:546:28)
at Request.self.callback (/home/node/io_hubspot/node_modules/request/request.js:185:22)
at Request.emit (events.js:321:20)
at Request.<anonymous> (/home/node/io_hubspot/node_modules/request/request.js:1161:10)
at Request.emit (events.js:321:20)
at IncomingMessage.<anonymous> (/home/node/io_hubspot/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:427:28)
at IncomingMessage.emit (events.js:333:22)
at endReadableNT (_stream_readable.js:1201:12)

As it's not returning an error for line # 529 an body is undefined on line 538.
I'm not sure if we have other situations where body is allowed to be undefined, could we:

if (error || body === undefined) {
   callback(undefined, undefined, undefined); // can even add an error in here
}  

Otherwise perhaps add this check after line # 539

if (actual_body === undefined) {
   callback(undefined, undefined, undefined);
}

Otherwise:
line # 546

if (actual_body !== undefined && actual_body !== null && actual_body.hasOwnProperty('error') actual_body.error && actual_body.error.code)

But looks overkill...

I haven't checked much into the rest of the code, so I'm not sure which style would suite you best or if any of this fixes looks good to you. I can do a PR with any if you prefer.

from nsrestlet.

MichaelEPope avatar MichaelEPope commented on June 12, 2024

Hey @mritzco thanks for catching that error. I'll try and push a corrected version up in the next two weeks that (hopefully) catches that.

Sorry about the late response, and hope your week is going well :)

from nsrestlet.

muh-awais avatar muh-awais commented on June 12, 2024

Hey @MichaelEPope, Can you please upgrade your package after resolving all of the above issues. Thanks and regards.

from nsrestlet.

babeard avatar babeard commented on June 12, 2024

I am also sporadically hitting this error. Any updates on this?

from nsrestlet.

bluedge avatar bluedge commented on June 12, 2024

I hit the same issue sometimes. @MichaelEPope
How about this simple/efficient fix line 546?
if (actual_body?.error && actual_body.error?.code)

from nsrestlet.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.