Skip to content

Patch thrift package so it handles transport errors with a corresponding opertion's callback - #99

Merged
kravets-levko merged 3 commits into
mainfrom
fix-error-handling
Dec 21, 2022
Merged

Patch thrift package so it handles transport errors with a corresponding opertion's callback#99
kravets-levko merged 3 commits into
mainfrom
fix-error-handling

Conversation

@kravets-levko

Copy link
Copy Markdown
Contributor

Nodejs thrift package is build in a way that only errors returned in Thrift RPC response message will be passed to an operation's callback. All other errors, e.g. failed request, non-2xx HTTP response, etc. will be just emitted on connection object.

This PR adds a local patch for a thrift package which allows to pass HTTP errors to operation callback which later could be handled in .catch() handlers. It becomes possible to examine error object and find out why particular operation failed. It could be useful, for example, for re-trying particular request if it failed due to HTTP 5xx error, etc.

…nding opertion's callback
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
@codecov-commenter

This comment was marked as resolved.

…sociated with operation
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
@nithinkdb
nithinkdb self-requested a review as a code ownerDecember 20, 2022 23:26
}

responseCallback.call(this.connection, response);
responseCallback.call(this.connection, response, ...rest);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any size limitations on this? I assume this will never cause stack overflow due to ... right?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's 100% safe

@kravets-levko
kravets-levko merged commit 88f8743 into mainDec 21, 2022
@kravets-levko
kravets-levko deleted the fix-error-handling branch December 21, 2022 07:00
nithinkdb added a commit to nithinkdb/databricks-sql-nodejs that referenced this pull request Jan 6, 2023
…nding opertion's callback (databricks#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>
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
@fjakobs

Copy link
Copy Markdown
Contributor

Thanks for releasing this. Makes my code a lot simpler.

@kravets-levko

Copy link
Copy Markdown
ContributorAuthor

Hi @fjakobs! Sadly, we've noticed some issues with this patch, but we're working on fixing it. More updates will be ASAP. Also, we're going to release library more often to faster deliver changes to users

kravets-levko added a commit that referenced this pull request Mar 21, 2023
* 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>
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Temp
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Initial commit
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Added retry helper
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Changed error handler
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Fixed linting
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Fixed mocharc
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Evaded ts rule
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Added lint ignore
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
* Removed legacy comment
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
---------
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
Signed-off-by: nithinkdb <nithin.krishnamurthi@databricks.com>
Co-authored-by: Levko Kravets <levko.ne@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@kravets-levko@codecov-commenter@fjakobs@nithinkdb