Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1990

Node.js Exceptions Don't Work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 0.7, 0.9
    • None
    • Node.js - Library
    • Ubuntu 13.04, Node.js v0.8.14

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            nd987 Nick Daugherty
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: