InputBufferUnderrunError at connection.js:171 with strange instanceof behavior
#1,263 opened on Oct 28, 2020
Description
When trying to access Hive 2.1, /node_modules/jshs2/node_modules/thrift/lib/nodejs/lib/thrift/connection.js:171 throws the exception InputBufferUnderrunError:
/home/beabloo/beabloo-prototype/node_modules/jshs2/node_modules/thrift/lib/nodejs/lib/thrift/connection.js:171
throw e;
^
InputBufferUnderrunError
at TBufferedTransport.ensureAvailable (/home/beabloo/beabloo-prototype/node_modules/@cubejs-backend/hive-driver/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js:89:11)
at TBufferedTransport.readI32 (/home/beabloo/beabloo-prototype/node_modules/@cubejs-backend/hive-driver/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js:114:8)
at TBinaryProtocol.readI32 (/home/beabloo/beabloo-prototype/node_modules/jshs2/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js:268:21)
at TBinaryProtocol.readMessageBegin (/home/beabloo/beabloo-prototype/node_modules/jshs2/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js:178:17)
at /home/beabloo/beabloo-prototype/node_modules/jshs2/node_modules/thrift/lib/nodejs/lib/thrift/connection.js:124:30
at /home/beabloo/beabloo-prototype/node_modules/@cubejs-backend/hive-driver/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js:48:5
at frames.filter.map.f (/home/beabloo/beabloo-prototype/node_modules/@cubejs-backend/hive-driver/driver/TSaslTransport.js:105:52)
at Array.map (<anonymous>)
at Socket.<anonymous> (/home/beabloo/beabloo-prototype/node_modules/@cubejs-backend/hive-driver/driver/TSaslTransport.js:105:43)
at Socket.emit (events.js:182:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cubejs-dashboards@0.0.1 dev: `node index.js`
This seems to be related to Thrift needing more buffer, but the really weird behavior is at instanceof at connection.js:171 :
catch (e) {
if (e instanceof InputBufferUnderrunError) {
transport_with_data.rollbackPosition(); // [1]
}
else {
throw e; // <---- The exception goes to here
}
}
But as you can see, the Exception is InputBufferUnderrunError, so should have executed [1]. The exception is thrown in the former try, at line 124, as can be seen in the stacktrace.
The issue is that instanceof does not recognize e as instance of InputBufferUndrrunError, though the own stacktrace shows it is.
Furthemore, with the following workaround it passes that point correctly:
catch (e) {
if (e instanceof InputBufferUnderrunError || e.name=="InputBufferUnderrunError") {
transport_with_data.rollbackPosition();
}
although then shows "UnhandledPromiseRejectionWarning: Error: Error: Cannot read property 'execute' of undefined" in other point of the code.
I know from StackOverflow that something like that happened with Babel 5 and subclases of Error, but I don't know nodejs to tackle it, debug it, and bring the complete problem and solution :(
Does anyone knows why instanceof doesn't work?
Version: Hive version : HDP Hive 1.2.1 & HDP Hive 2.1.0 (Interactive Queries) npm --version : 6.14.8 nodejs --version : v10.14.0 cubejs : 0.22
Thank you.