Nick Daugherty created THRIFT-1990:
--------------------------------------

             Summary: Node.js Exceptions Don't Work
                 Key: THRIFT-1990
                 URL: https://issues.apache.org/jira/browse/THRIFT-1990
             Project: Thrift
          Issue Type: Bug
          Components: Node.js - Library
    Affects Versions: 0.9, 0.7, 1.0
         Environment: Ubuntu 13.04, Node.js v0.8.14
            Reporter: Nick Daugherty


Exception passing / handling doesn't seem to be working in the Node.js library. 
If the Thrift server throws an exception, the client code does not see an 
error, and instead is passed a return value. The expected behavior is a server 
Exception would be exposed as 'err', the first argument to the client callback. 

Have verified using my own code and the supplied example code by adding a 
simple Exception type to my .thrift file, regenerating, then stubbing out the 
server methods to always error.

Have tried all transports, using the multitransport examples.

For example, with the following exception definition:

exception NotFoundException {
        1: string message
}

and the following server method implementation:

var store = function(user, result) {
        return result(new ttypes.NotFoundException({message:'failed!'}));
};

This client invocation will never receive an error in the callback, and will in 
fact be passed an empty instance of whatever the return value is supposed to 
be. For example, if a method returns a custom data type, the callback receives 
an instance of the custom data type with all members set to null.

f_client.store(user1, function(err, response) {
  if (err) { console.error(err); return; } // This never actually happens, 
because err is always null!

  console.log("stored:", user1.uid, " as ", user1.name);
  b_client.retrieve(user1.uid, function(err, responseUser) {
    if (err) { console.error(err); return; }
    console.log("retrieved:", responseUser.uid, " as ", responseUser.name);
  });
});

I noticed that the Exception objects seem to be written to the wire correctly - 
in the generated js file, the Exception class's .write() method appears to fire 
correctly. However, the .read() never goes off, so it's getting lost somewhere 
in between.

Shouldn't matter, but the client and server are both on the same machine.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to