ufukomer / node-impala

Node Client for Impala using Apache Thrift
https://www.npmjs.com/package/node-impala
MIT License
31 stars 12 forks source link

Unexpected behaviour using promises on closing #6

Closed karladler closed 7 years ago

karladler commented 8 years ago

When I use then on connection close it seems not to executed. But the connection seems to be closed and there is no error raised. Is that intentional behaviour?

client.close()
    .then( () => {
       console.log('closed.'); // never logged
       this.closed = true; 
    })
    .catch(err => console.error(err));

My use case: I wanted to keep the connection open while firing requests parallel. Therefore I need the state whether the connection is already open or not. Is there a built in method to do so?

ufukomer commented 8 years ago

This is not possible for now. Maybe method for multi query would handle your task. If it's enough I would add. What do you suggest?

karladler commented 8 years ago

I guess there is not really the chance that closing connection fails when a proper connection is established, so I just moved the logic outside the promise. A multi query method could be helpful, but it's not necessary in my case.

console.log('closing connection....');
this.closed = true; 
client.close() .catch(err => console.error(err));
ufukomer commented 7 years ago

Maybe that fixed the close issue https://github.com/ufukomer/node-impala/commit/46bee5374125a032d6ce909cfc95276dcca54f61#diff-1351a7ff46327e01f6f417e43874d645R68