Azure / azure-sdk-for-node

Azure SDK for Node.js - Documentation
https://github.com/Azure/azure-sdk-for-node#documentation
MIT License
1.19k stars 566 forks source link

ServiceBus createTopicIfNotExists fails with TypeError: Cannot set property 'body' of null #498

Closed tmrudick closed 11 years ago

tmrudick commented 11 years ago

Test estimate: 1

I was trying to run createTopicIfNotExists and incorrectly typed in my endpoint and key combination so that my service bus object was invalid.

When I attempt to run createTopicIfNotExists, an unhandled error is thrown from within the service bus code:

C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:210
        finalRequestOptions.body = body.outputData;
                                 ^
TypeError: Cannot set property 'body' of null
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:210:34
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:264:7
    at ServiceBusService.filter (C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:534:7)
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:261:10
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\servicebusserviceclient.js:104:5
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\serviceBus\wrap.js:69:5
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\serviceBus\wraptokenmanager.js:76:5
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\serviceBus\wrapservice.js:98:7
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\core\serviceclient.js:538:11
    at C:\src\scratch\azuresdk\node_modules\azure\lib\services\serviceBus\wrapservice.js:101:5

Repro code:

var azure = require('azure');

// Succeeds.
var serviceBusService = azure.createServiceBusService('servicebus-test', 'ThisIsMykey');

// fails, but the error argument is not ever read by either code path.
serviceBusService.createTopicIfNotExists('MobileServicesTopic', function(error){
    if(!error){
        // Topic was created or exists
        console.log("The topic was created or already exists");
    }
    else {
        console.log("There was an error creating the topic", error);
  }
});

I would expect an error to be passed into my callback function letting me know that my configuration is incorrect instead of throwing this error which is only catchable with a global error handler.

markcowl commented 11 years ago

@tmrudick what node and sdk versions are you using?

tmrudick commented 11 years ago

This is on node v0.6.20 and v0.6.8 of the azure node sdk.

andrerod commented 11 years ago

This is related to error handling. im taking this one.

markcowl commented 11 years ago

verified in unit test