You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vartoken=process.env.DATABRICKS_TOKENvarserverHostname=process.env.DATABRICKS_SERVER_HOSTNAMEvarhttpPath=process.env.DATABRICKS_HTTP_PATHapp.get("/people",(_,res)=>{try{letclient=nullclient=newDBSQLClient()//const utils = DBSQLClient.utilsclient.connect((options={token: token,host: serverHostname,path: httpPath,})).then(async(client)=>{
### **_// this throws a 503 level error until the cluster is awake_**constsession=awaitclient.openSession()constqueryOperation=awaitsession.executeStatement((statement="SELECT * FROM default.people ORDER BY LastName"),(options={runAsync: true,maxRows: 10000,// This option enables the direct results feature.}))constresult=awaitqueryOperation.fetchAll({progress: false,callback: ()=>{},})awaitqueryOperation.close()res.send(result)awaitsession.close()awaitclient.close()})**_### // this doesn't get fired at all._**.catch((error)=>{res.send(error)})}catch(error){res.send(error)}})
Server is running on port 3001
node:events:491
throw er; // Unhandled 'error' event
^
THTTPException: Received a response with a bad HTTP status code: 503
at exports.HttpConnection.responseCallback (/Users/jason/SourceCode/mock_api/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js:173:26)
at ClientRequest.connection.responseCallback (/Users/jason/SourceCode/mock_api/node_modules/@databricks/sql/dist/connection/connections/HttpConnection.js:64:30)
at Object.onceWrapper (node:events:628:26)
at ClientRequest.emit (node:events:513:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:674:27)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
at TLSSocket.socketOnData (node:_http_client:521:22)
at TLSSocket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
Emitted 'error' event on DBSQLClient instance at:
at exports.HttpConnection.<anonymous> (/Users/jason/SourceCode/mock_api/node_modules/@databricks/sql/dist/DBSQLClient.js:68:22)
at exports.HttpConnection.emit (node:events:513:28)
at exports.HttpConnection.responseCallback (/Users/jason/SourceCode/mock_api/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js:173:12)
at ClientRequest.connection.responseCallback (/Users/jason/SourceCode/mock_api/node_modules/@databricks/sql/dist/connection/connections/HttpConnection.js:64:30)
[... lines matching original stack trace ...]
at TLSSocket.emit (node:events:513:28) {
This is due to the way you guys produce known exceptions you guys emit custom errors using node event emitter due to that catch handler couldn't able to catch this
this.emit("error", new THTTPException(response)); // from databricks sdk source code
Hi @harinduliyanage! Can you please point me to exact line where you found that code fragment? Re. event emitter: TBH I don't like the fact we have use it, but some errors (like http errors) that come from Thrift library could be handled only this way - Thrift lib doesn't propagate that errors to corresponding request handler but instead just emits an event
This error sucks since it's inconsistent and hard to reproduce on my end.
{"level":"error","message":"THTTPException: Received a response with a bad HTTP status code: 503\n at exports.HttpConnection.responseCallback (/src/app/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js:173:26)\n at ClientRequest.connection.responseCallback (/src/app/node_modules/@sheing/databricks-sql/dist/connection/connections/HttpConnection.js:67:30)\n at Object.onceWrapper (node:events:628:26)\n at ClientRequest.emit (node:events:513:28)\n at ClientRequest.emit (node:domain:489:12)\n at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:693:27)\n at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)\n at HTTPParser.execute (<anonymous>)\n at TLSSocket.socketOnData (node:_http_client:534:22)\n at TLSSocket.emit (node:events:513:28)"}
I ran into a similar issue. In our application, a bad token resulted in openSession failing silently. For testing purposes, it may be easier to provoke a 403 error, and ensure that errors are handled or at least propagated. Here's a quick work around, but ymmv.
This uses a promise to capture the event from the event emitter. If an error occurs, the promise will reject and await will convert the rejection into an exception.
I'm closing this issue as in newer library versions we significantly improved error handling. Please feel free to re-open this issue if you still experience the same errors, or file a new issue if needed
Activity
kravets-levko commentedon Oct 18, 2022
Hi @wheelie33! Can you please attach an output from your script so I can see the exact error?
wheelie33 commentedon Oct 18, 2022
wheelie33 commentedon Oct 18, 2022
Here's the log for the unhandled exception
kravets-levko commentedon Oct 20, 2022
Hi @wheelie33! Thank you for logs and code example. I managed to reproduce this error, and once I find what causes it - I'll get back to you
kravets-levko commentedon Oct 20, 2022
@wheelie33 can you please also tell me which version of this connector you use? thank you!
wheelie33 commentedon Oct 20, 2022
harinduliyanage commentedon Nov 3, 2022
This is due to the way you guys produce known exceptions you guys emit custom errors using node event emitter due to that catch handler couldn't able to catch this
this.emit("error", new THTTPException(response)); // from databricks sdk source code
kravets-levko commentedon Nov 3, 2022
Hi @harinduliyanage! Can you please point me to exact line where you found that code fragment? Re. event emitter: TBH I don't like the fact we have use it, but some errors (like http errors) that come from Thrift library could be handled only this way - Thrift lib doesn't propagate that errors to corresponding request handler but instead just emits an event
Sheing commentedon Dec 4, 2022
@harinduliyanage @kravets-levko Did you guys figure out how to prevent THTTPException?
This error sucks since it's inconsistent and hard to reproduce on my end.
tonious commentedon Dec 8, 2022
I ran into a similar issue. In our application, a bad token resulted in
openSessionfailing silently. For testing purposes, it may be easier to provoke a 403 error, and ensure that errors are handled or at least propagated. Here's a quick work around, but ymmv.This uses a promise to capture the event from the event emitter. If an error occurs, the promise will reject and
awaitwill convert the rejection into an exception.kravets-levko commentedon Aug 31, 2023
@wheelie33 do you still encounter this issue with newer library versions? Please let me know in either case. Thank you!
kravets-levko commentedon Jan 18, 2024
I'm closing this issue as in newer library versions we significantly improved error handling. Please feel free to re-open this issue if you still experience the same errors, or file a new issue if needed
test(sea): F4 round-3 — inline-result-set (SELECT 1) edge case
test(sea): F4 round-3 — inline-result-set (SELECT 1) edge case