prosociallearnEU / cf-nodejs-client

A Cloud Foundry Client for Node.js
https://prosociallearneu.github.io/cf-nodejs-client/
Apache License 2.0
17 stars 41 forks source link

Error uploading app #169

Closed jsloyer closed 8 years ago

jsloyer commented 8 years ago

When uploading an app with the following code I get an error with the callback for the response, it seems its ending early with write after end.

const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint);
const UsersUAA = new (require("cf-nodejs-client")).UsersUAA;
const Apps = new (require("cf-nodejs-client")).Apps(endpoint);

CloudController.getInfo().then( (result) => {
    UsersUAA.setEndPoint(result.authorization_endpoint);
    return UsersUAA.login(username, password);
}).then( (result) => {
    Apps.setToken(result);
    return Apps.add({name: "testing", space_guid: space});
}).then( (result) => {
    console.log(result);
    var appGuid = result.metadata.guid;
    return Apps.upload(appGuid, appPath);
}).then( (result) => {
    console.log(result);
}).catch( (reason) => {
    console.error("Error: " + reason);
});

Error stack:

[Error: write after end]
null
/Users/jsloyer/Downloads/node_modules/cf-nodejs-client/lib/utils/HttpUtils.js:107
                    if (response.statusCode === httpStatusAssert) {
                                ^

TypeError: Cannot read property 'statusCode' of null
    at Request.<anonymous> (/Users/jsloyer/Downloads/node_modules/cf-nodejs-client/lib/utils/HttpUtils.js:107:33)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.mixin._fireError (/Users/jsloyer/Downloads/node_modules/cf-nodejs-client/node_modules/restler/lib/restler.js:207:10)
    at ClientRequest.<anonymous> (/Users/jsloyer/Downloads/node_modules/cf-nodejs-client/node_modules/restler/lib/restler.js:246:14)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at writeAfterEndNT (_http_outgoing.js:490:8)
    at nextTickCallbackWith3Args (node.js:448:9)
    at process._tickCallback (node.js:354:17)
jsloyer commented 8 years ago

Looks like the underlying cause is I was passing it a folder for the app location instead of a zip file, PR coming soon...

jsloyer commented 8 years ago

closing in favor of #176