Skip to content

Commit 88f8743

Browse files
Patch thrift package so it handles transport errors with a corresponding opertion's callback (#99)
* Patch `thrift` package so it handles transport errors with a corresponding opertion's callback Signed-off-by: Levko Kravets <levko.ne@gmail.com> * Export Thrift error types; do not emit error event if error can be associated with operation Signed-off-by: Levko Kravets <levko.ne@gmail.com> Signed-off-by: Levko Kravets <levko.ne@gmail.com> Co-authored-by: Nithin Krishnamurthi <110488533+nithinkdb@users.noreply.github.com>
1 parent 6c977b7 commit 88f8743

File tree

5 files changed

+565
-68
lines changed

5 files changed

+565
-68
lines changed

lib/connection/connections/HttpConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class HttpConnection implements IConnectionProvider, IThriftConne
8686
private addCookieHandler() {
8787
const { responseCallback } = this.connection;
8888

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

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

99-
responseCallback.call(this.connection, response);
99+
responseCallback.call(this.connection, response, ...rest);
100100
};
101101
}
102102
}

lib/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Thrift } from 'thrift';
12
import TCLIService from '../thrift/TCLIService';
23
import TCLIService_types from '../thrift/TCLIService_types';
34
import DBSQLClient from './DBSQLClient';
@@ -14,6 +15,11 @@ export const auth = {
1415
PlainHttpAuthentication,
1516
};
1617

18+
const { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType } =
19+
Thrift;
20+
21+
export { TException, TApplicationException, TApplicationExceptionType, TProtocolException, TProtocolExceptionType };
22+
1723
export const connections = {
1824
HttpConnection,
1925
};

0 commit comments

Comments
 (0)