-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
TypeError: Cannot read property 'headers' of undefined at getPaginated #142
Comments
hmm, ill look! |
What version of the package are you using? And do you have problems running any of the other functions? |
Ah sorry, |
Hmm thats really odd... Looking! |
Could you check if you get the same problem in an earlier version of the package? |
Can do, let's just make sure this is not a user error first though, are you expecting the Edit: same issue in |
I append it internally, the url just need to be the base url, like: https://gitlab.com |
Heh, okay, it's a certificate issue. I'm behind a proxy. Logging the
Basically. |
😂 woo, glad we figured it out |
Hmm wonder how I can get around it... bit weird that it doesn't happen when hitting the API directly |
hmm, could it be an issue with the Request module? Can you access the API directly through the Request module ? |
Do you mean the |
Nope, i mean with the Request Library: https://www.npmjs.com/package/request |
Ah right so you're using this to perform the requests, let me try. |
yup! It will help narrow down where the error is coming from |
Okay yeah, happens there too. I can get around it by passing an option to the call like
Are all options passed to the constructor passed down to the request call? If so then passing this as an option should just work. |
No the options are not passed down :( If there another way around that problem? |
I don't think so. It's a legit use case imo because in some corporate environments, non standard certs are used or certificates are not managed by the developers themselves making it hard to have any kind of control over them. Given that GitLab focuses on self-hosting, I think this would be a good option to include. Let me know if you think so and I'll see if I can get a PR done. |
Hmm, i agree. How does this flag work with other request modules? For example we use the XMLHttpRequest module as well in this library ? (Eventually to be refactored out to support any request module the user would like #98 |
Any reason why you are using two libraries? Why not just use one? |
I started with the Request module because it was one of the most used/well tested request modules i could find. The XML request module was added after to support xhr request for the browser. A better library to upgrade to may be cross-fetch, which handles all of these cases. Before switching the main request library around, id like to do more research to at least try and maintain the same API if possible instead of having to update everything |
Ah okay makes sense. I think |
Meh, this library was build specifically for node, so whether it maintains adherence to the browser spec is less important. As long as it is consistent s'all good. Another one another contributor suggested was axios? |
I wouldn't use Axios personally. Fetch is the way forward. Get what you're saying about it being node specific, but supporting browsers is also nice because it means people can use your lib to create some cool UIs. |
I think this is actually an issue with the node-gitlab library and not just the request package. We use this library in the browser with the XMLHttpRequester and we get the same error whenever a request fails.
This happens for example when making a request to a repository that the user does not have access to. Previously the real HTTP error was passed to the error function. I think that it's coming from the bit of code that tries to get the sleep time from the 'retry-after' header.
Let me know if you need any more information. I can also try to make a small sample to reproduce the error. |
Hmm, alright I'll look into it tonight
…On Aug 9, 2018, 11:49 AM, at 11:49 AM, Martin Benninger ***@***.***> wrote:
I think this is actually an issue with the node-gitlab library and not
just the request package.
We use this library in the browser with the XMLHttpRequester and we get
the same error whenever a request fails.
`TypeError: Cannot read property 'headers' of undefined`
This happens for example when making a request to a repository that the
user does not have access to. Previously the real HTTP error was passed
to the error function.
I think that it's coming from the bit of code that tries to get the
sleep time from the 'retry-after' header.
`const sleepTime = parseInt(err.response.headers['retry-after'], 10);`
Let me know if you need any more information. I can also try to make a
small sample to reproduce the error.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#142 (comment)
|
@rohan-deshpande and @MartinBenninger even still you should be able to include the extra certs into NodeJS this is how it should be solved you don't want to start down the dark path of ignore certs. Added this to our package.json and the pem includes all our internal certs 😄 Has been working great for us. "scripts": {
"start": "NODE_EXTRA_CA_CERTS=./secrets/3ShapeCA.pem node bot.js"
}, https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file |
There are two problems in this issue lol 1. Certificates but @Casz has pointed out how to handle that, and 2. The sleep propagating |
Pushed up a fix for the headers |
I don’t think the suggested solution works if your certificates are borked. Which mine are, and I have no control over them. It’s not a viable solution for everyone where as passing the I’ve fallen back to just hitting the API directly with |
Hmm, I guess so eh. I'll add the extra param then to the init logic. |
# [3.9.0](3.8.0...3.9.0) (2018-08-15) ### Bug Fixes * Fix error while throwing an error in RequestHelper ([#156](#156)) ([177d7fd](177d7fd)) * Handling errors before retrying request ([#142](#142)) [skip-ci] ([bc3b366](bc3b366)) * Linting Master ([#157](#157)) ([ab14ed7](ab14ed7)) ### Features * Add deploy keys enable functionality ([#155](#155)) thanks to [Michael Matzka](https://github.com/mimaidms ) ([66547ad](66547ad))
@rohan-deshpande you really ought to handle certs in the way that I suggested above. This other way is just an excuse. If you want to include more you simply add them all into one pem file, there is really no excuse to not doing it. You can also run: |
Of course I’ve already tried this. The certs are not actually valid. That’s the problem. I don’t think it’s helpful to assume that everything is as it should be in the myriad of corporate mess that others have to deal with. |
Although i agree with @Casz , I see your point. If the user of the library is ok with ignoring certs that's their business. |
I agree 100% in principle as well. It’s just that these things aren’t always as they should be. |
Allows to be set service wide or on individual request fixes #142
🎉 This issue has been resolved in version 3.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Nice one, thanks. |
# [3.9.0](jdalrymple/gitbeaker@3.8.0...3.9.0) (2018-08-15) ### Bug Fixes * Fix error while throwing an error in RequestHelper ([jdalrymple#156](jdalrymple#156)) ([177d7fd](jdalrymple@177d7fd)) * Handling errors before retrying request ([jdalrymple#142](jdalrymple#142)) [skip-ci] ([bc3b366](jdalrymple@bc3b366)) * Linting Master ([jdalrymple#157](jdalrymple#157)) ([ab14ed7](jdalrymple@ab14ed7)) ### Features * Add deploy keys enable functionality ([jdalrymple#155](jdalrymple#155)) thanks to [Michael Matzka](https://github.com/mimaidms ) ([66547ad](jdalrymple@66547ad))
Allows to be set service wide or on individual request fixes jdalrymple#142
# [3.10.0](jdalrymple/gitbeaker@3.9.0...3.10.0) (2018-08-15) ### Features * Expose reject unauthorized in request helper ([jdalrymple#160](jdalrymple#160)) ([01a2ce2](jdalrymple@01a2ce2)), closes [jdalrymple#142](jdalrymple#142)
After upgrading my version of `node-gitlab` I noticed that I the API broke as result of these error messages: `Error: self signed certificate`. I was really confused why this was happening even though I had `process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';` set in my file. Turns out this work jdalrymple#142 added a special flag to Gitlab's BaseModel to specifically handle rejections of certificates. This PR adds documentation for it so that others running into this issue won't waste their time going down the same rabbit hole I went on.
Error is occurring at
RequestHelper.js:116:44
when attempting the followingNote that I can access the projects via postman with
The text was updated successfully, but these errors were encountered: