This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.07k
stars
1.19k
forks
source link
[Event Hubs] Websocket errors in node are translated to [object Object] #29294
Expected behaviorCbsSession.init should throw something like Error: getaddrinfo ENOTFOUND example.invalid.
Actual behaviorCbsSession.init throws an error with a meaningless message:
Error: [object Object]
at translate (C:\Code\azure-websocket-error-repro\node_modules\@azure\core-amqp\dist\index.js:1076:42)
at CbsClient.init (C:\Code\azure-websocket-error-repro\node_modules\@azure\core-amqp\dist\index.js:1688:37)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Additional context
This is a minimal repro case. The real world scenario involves @azure/event-hubs and intermittent internet connection.
The websocket library throws an ErrorEvent object and core-amqptries to convert it to a string, producing [object Object]. Earlier in that function, there's code handling websocket errors, but it doesn't cover node and doesn't propagate the specific error either.
Screenshots
The actual error in my real world scenario.
Describe the bug CbsClient throws
Error: [object Object]
instead of the actual error when using websocket in node.To Reproduce Steps to reproduce the behavior:
@azure/core-amqp
andws
repro.js
node repro.js
repro.js contents
```javascript const { ConnectionContextBase } = require('@azure/core-amqp'); const { WebSocket } = require('ws'); const ctx = ConnectionContextBase.create({ config: { webSocket: WebSocket, endpoint: 'sb://example.invalid/', host: 'example.invalid', connectionString: 'Endpoint=sb://example.invalid/', sharedAccessKeyName: 'test', sharedAccessKey: 'test', }, connectionProperties: { userAgent: 'test', }, }); ctx.cbsSession.init() .catch(console.log); ```Expected behavior
CbsSession.init
should throw something likeError: getaddrinfo ENOTFOUND example.invalid
.Actual behavior
CbsSession.init
throws an error with a meaningless message:Additional context This is a minimal repro case. The real world scenario involves
@azure/event-hubs
and intermittent internet connection.The websocket library throws an
ErrorEvent
object andcore-amqp
tries to convert it to a string, producing[object Object]
. Earlier in that function, there's code handling websocket errors, but it doesn't cover node and doesn't propagate the specific error either.Screenshots The actual error in my real world scenario.