Skip to content

Commit

Permalink
Patch thrift package so it handles transport errors with a correspo…
Browse files Browse the repository at this point in the history
…nding opertion's callback (#99)

* Patch `thrift` package so it handles transport errors with a corresponding opertion's callback

Signed-off-by: Levko Kravets <[email protected]>

* Export Thrift error types; do not emit error event if error can be associated with operation

Signed-off-by: Levko Kravets <[email protected]>

Signed-off-by: Levko Kravets <[email protected]>
Co-authored-by: Nithin Krishnamurthi <[email protected]>
  • Loading branch information
kravets-levko and nithinkdb authored Dec 21, 2022
1 parent 6c977b7 commit 88f8743
Show file tree
Hide file tree
Showing 5 changed files with 565 additions and 68 deletions.
4 changes: 2 additions & 2 deletions lib/connection/connections/HttpConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class HttpConnection implements IConnectionProvider, IThriftConne
private addCookieHandler() {
const { responseCallback } = this.connection;

this.connection.responseCallback = (response: IncomingMessage) => {
this.connection.responseCallback = (response: IncomingMessage, ...rest: Array<unknown>) => {
if (Array.isArray(response.headers['set-cookie'])) {
const cookie = [this.connection.nodeOptions.headers.cookie];

Expand All @@ -96,7 +96,7 @@ export default class HttpConnection implements IConnectionProvider, IThriftConne
.join(';');
}

responseCallback.call(this.connection, response);
responseCallback.call(this.connection, response, ...rest);
};
}
}
6 changes: 6 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Thrift } from 'thrift';
import TCLIService from '../thrift/TCLIService';
import TCLIService_types from '../thrift/TCLIService_types';
import DBSQLClient from './DBSQLClient';
Expand All @@ -14,6 +15,11 @@ export const auth = {
PlainHttpAuthentication,
};

const { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType } =
Thrift;

export { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType };

export const connections = {
HttpConnection,
};
Expand Down
Loading

0 comments on commit 88f8743

Please sign in to comment.