I'm trying to do a simple thrift serialize/deserialize however my deserialization if failing with the following message:
/home/przemek/workspace/leviathan/node_modules/thrift/lib/thrift/protocol.js:350
throw Error("Invalid type: " + type);
^
Error: Invalid type:
at Error (unknown source)
at TBinaryProtocol.skip (/home/przemek/workspace/leviathan/node_modules/thrift/lib/thrift/protocol.js:350:13)
at Object.Profile.read (/home/przemek/workspace/leviathan/gen-nodejs/Profile_types.js:49:15)
at deserialize (/home/przemek/workspace/leviathan/client.js:43:13)
at /home/przemek/workspace/leviathan/client.js:51:2
at serialize (/home/przemek/workspace/leviathan/client.js:35:3)
at Object.<anonymous> (/home/przemek/workspace/leviathan/client.js:49:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
I don't understand why this is happening. To me this error message sounds like it is getting the wrong type but my serialization works so the serialized object should have the correct types. This error is being thrown by the protocol.js file when doing TBinaryProtocol.prototype.skip. Here is my code:
function serialize(data, callback) {
var buffer = new Buffer(data);
var transport = new thrift.TFramedTransport(buffer);
var protocol = new thrift.TBinaryProtocol(transport);
data.write(protocol);
callback(transport.outBuffers)
}
function deserialize(data, callback){
var transport = new thrift.TFramedTransport(data);
var protocol = new thrift.TBinaryProtocol(transport);
var aProfile = new profile.Profile();
aProfile.read(protocol);
callback(aProfile);
}
var aProfile = new profile.Profile({exposure:2,kineticCycleTime:3});
serialize(aProfile, function(serialized){
log('serialization complete:' + serialized);
deserialize(serialized, function(deserialized){
log('deserialization complete');
log(JSON.stringify(deserialized));
});
});