moul / node-gitlab

DEPRECATED, see https://github.com/node-gitlab/node-gitlab
https://npmjs.org/package/gitlab
Other
470 stars 140 forks source link

Cannot read property 'body' of null #136

Closed mildfuzz closed 8 years ago

mildfuzz commented 8 years ago

lifting my code pretty much straight from the readme:

const Gitlab = require('gitlab');
const gitlab = new Gitlab({
  url: 'https://gitlab.mydomain.com/',
  token: 'myToken'
});

// Listing users
gitlab.users.all(function(users) {
  for (var i = 0; i < users.length; i++) {
    console.log("#" + users[i].id + ": " + users[i].email + ", " + users[i].name + ", " + users[i].created_at);
  }
});

yields the following error:

TypeError: Cannot read property 'body' of null
    at /Users/john/Workspace/handyman/node_modules/gitlab/lib/ApiBaseHTTP.js:88:56
    at _Class.wrap_response (/Users/john/Workspace/handyman/node_modules/slumber/lib/API.js:197:18)
    at _Class.wrap_response (/Users/john/Workspace/handyman/node_modules/slumber/lib/API.js:4:59)
    at Request._callback (/Users/john/Workspace/handyman/node_modules/slumber/lib/API.js:215:26)
    at self.callback (/Users/john/Workspace/handyman/node_modules/request/request.js:200:22)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/Users/john/Workspace/handyman/node_modules/request/request.js:831:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)

I am able to hit the API in my browser directly.

kai23 commented 8 years ago

Same issue here.

slumber:api GET +4ms https://git.xxxxxx.xxxxxxxx/api/v3/projects/87/milestones?page=1&per_page=100
[Error: write after end]
mildfuzz commented 8 years ago

looks like this is a node version issue.

Tested with 6.2.1, 5.0.0, 4.0.0 and 0.11.3

Only working with 0.11.3

kai23 commented 8 years ago

It worked well in 5.10.1 but it doesn't, now. Is it a gitlab upgrade fault ?

mildfuzz commented 8 years ago

Gitlab version 5.10.1? or Node? I am talking about Node versions

kai23 commented 8 years ago

I'm talking about node version. Gitlab is in 8.9.4

mildfuzz commented 8 years ago

ahh, okay. I tested that version of node too, but did not work for me.

kai23 commented 8 years ago

It doesn't for me, too. But It worked last week. In between, we've upgraded our gitlab to the 8.9.4, that's why I thought it could be the cause of this. Which version of Gitlab do you use ?

fuksman commented 8 years ago

I have the same issue. We are using GitLab on gitlab.com and this version is 8.9.5-ee (42dceaa).

josh-shaw-dev commented 8 years ago

So after some quick debugging it appears to be that slumber has been updated and the deps of node-gitlab have it as >=0.7.0 in package.json

Pinning it at 0.7.0 it works as expected so this is a bug/feature from npm installing a newer version due to the relaxed semver version dependencies.

Edit: 0.9.0 also seems to work as well. So Ill throw together a quick pr.

dave-irvine commented 8 years ago

Well, luckily we know the developer of slumber quite well so we shall ask him why he has broken it :) @moul Why have you broken it? :D

mildfuzz commented 8 years ago

good chat ;)

moul commented 8 years ago

:)

kahirul commented 7 years ago

Hi, this still happening. I Use node-gitlab in conjunction with node:8.1.2 docker image. I've updated the slumber to all of 0.7.0, 0.7.1, 0.9.0, 0.11.0 but it still is not working.

MichaelLeeHobbs commented 6 years ago

Same issue but only when the server is not reachable.