Commit 7ad3b45
committed
Actual fix for a.)crash on incorrect host b.)superagent gives us objects directly
The first commit's message is:
Crash on receiving bad data when listing projects
When there was a problem in the gitlab configuration and
an unreachable/incorrect hostname was specified, instead
of JSON, we were getting undefined from the get
method in api.js, and we were crashing.
Added an error message for this case so that we do not
crash.
Ideally we should be checking for a valid reachable gitlab
host when saving the configuration.
Crash trace below:
SyntaxError: Unexpected token u
at Object.parse (native)
at /home/dev/sandbox/strider/node_modules/strider-gitlab/lib/webapp.js:34:20
at /home/dev/sandbox/strider/node_modules/strider-gitlab/lib/api.js:45:16
at Request.callback (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/index.js:628:30)
at ClientRequest.<anonymous> (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/index.js:596:10)
at ClientRequest.emit (events.js:107:17)
at Socket.socketErrorListener (_http_client.js:271:9)
at Socket.emit (events.js:107:17)
at net.js:459:14
at process._tickCallback (node.js:355:11)
9284 died 1 null
This is the 2nd commit message:
superagent already parses JSON into objects for us
superagent is parsing the JSON received from
the API into Objects
per - https://visionmedia.github.io/superagent/#parsing-response%20bodies,
so in webapp.js, branches does not contain a JSON/string but an Object.
JSON.parse(branches) is failing with Unexpected token o
JSON.parse is perhaps not required - when getting a list of projects
and also when getting a list of branches. With the code as it stands,
we crash when trying to configure a project.
2015-08-05T05:05:48.543Z - error: strider-gitlab:webapp Getting URI projects/2/repository/branches +0ms
2015-08-05T05:05:48.573Z - error: strider-gitlab:api Response body type: object +0ms
undefined:1
[object Object]
^
SyntaxError: Unexpected token o
at Object.parse (native)
at /home/dev/sandbox/strider/node_modules/strider-gitlab/lib/webapp.js:68:23
at /home/dev/sandbox/strider/node_modules/strider-gitlab/lib/api.js:50:7
at Request.callback (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/index.js:628:30)
at Request.<anonymous> (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/index.js:131:10)
at Request.emit (events.js:107:17)
at Stream.<anonymous> (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/index.js:773:12)
at Stream.emit (events.js:129:20)
at Unzip.<anonymous> (/home/dev/sandbox/strider/node_modules/strider-gitlab/node_modules/superagent/lib/node/utils.js:124:12)
at Unzip.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
20518 died 1 null1 parent 492e40e commit 7ad3b45
2 files changed
+9
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| 60 | + | |
58 | 61 | | |
59 | | - | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
0 commit comments