azure-sdk-for-js
azure-sdk-for-js copied to clipboard
Cosmos ErrorResponse code typing should be number or string
- Package Name:
@azure/cosmos
- Package Version:
3.16.3
- Operating system:
- [X] nodejs
- [X] typescript
Describe the bug A clear and concise description of what the bug is.
Cosmos SDK is returning string values like ETIMEDOUT for ErrorResponse.code in addition to numbers, but the type in the interface is only set to number.
Types should be updated to indicate that the value may return either a number or a string.
@timtucker-dte can you provide a sample ErrorResponse?
Did some more looking and it looks like I had a bad assumption that I would be getting back an ErrorResponse on error.
It looks like what I'm getting back is a RestError from the underlying @azure/core-rest-pipeline:
Stack:
RestError: connect ETIMEDOUT REDACTED:443
at ClientRequest.<anonymous> (C:\home\site\wwwroot\node_modules\@azure\core-rest-pipeline\dist\index.js:1691:24)
at Object.onceWrapper (node:events:510:26)
at ClientRequest.clsBind (C:\home\site\wwwroot\node_modules\cls-hooked\context.js:172:17)
at ClientRequest.emit (node:events:402:35)
at ClientRequest.emit (node:domain:475:12)
at ClientRequest.emitted (C:\home\site\wwwroot\node_modules\emitter-listener\listener.js:134:21)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:157:8)
Error object:
RestError: connect ETIMEDOUT REDACTED:443
{
"name": "RestError",
"code": "ETIMEDOUT",
"request": {
"url": "https://REDACTED.documents.azure.com:443/dbs/DBNAME/colls/COLLECTION/docs/DOCUMENTID",
"headers": {
"x-ms-documentdb-responsecontinuationtokenlimitinkb": "REDACTED",
"x-ms-documentdb-query-enablecrosspartition": "REDACTED",