-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read properties of undefined (reading 'defaultPort')
when used with nock
#675
Comments
PETOSS-396 |
Thanks for raising an issue, a ticket has been created to track your request |
Have you had the chance to consider this issue? I'd be happy to submit a PR if you agree with the suggested change? |
Same issue here |
@TiddoLangerak The PR can maybe accelerate the fix :) |
@sangeet-joy-tw Can we have update on this please ? |
Hey, @sangeet-joy-tw Could we have an update on this, please? Thanks in advance 🙏 |
Hello @BenGDev @GraceYBR @JamesColemanXero @MattR-Api @MJMortimer @TheRegan Can you review and approve this PR please ? |
@manishT72 @manishT72x |
…t') when used with nock (#687) * Added the null check for default port * reverted open id verison change * new line --------- Co-authored-by: sangeet-joy_xero <[email protected]>
Hey @TiddoLangerak @QuentinLemCode @c4c1us We have addressed the port issue in our latest xero-node v7.0.0. Please install the latest version and kindly let us know if you guys are facing any more "undefined" issues with API Error class. |
SDK you're using (please complete the following information):
Describe the bug
When using Nock to mock requests to Xero then error responses result in a
Cannot read properties of undefined (reading 'defaultPort')
error triggered in the ApiError class.This appears to be caused by
xero-node
using an undocumentedhttp.ClientRequest.agent
property to fetch the port, which doesn't exist when using Nock (and possibly other mocking frameworks, too).To Reproduce
nock
to generate some kind of error response. For example:ApiError
Expected behavior
I expect an
ApiError
to be thrown, instead of acannot read properties of undefined
Screenshots
Additional context
http.ClientRequest.agent
is an undocumented property, it's likely not intended as a public facing API. There's a documented alternative available to get the port:request.socket.localPort
. So replacingwith
should give the same information, using a documented public api, and compatible with Nock.
The text was updated successfully, but these errors were encountered: