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
const{ DirectLineStreaming }=require('../lib/directLineStreaming');try{constdirectLine=newDirectLineStreaming({// Intentionally connecting to wrong domain.domain: 'https://bing.com/',secret: 'not-a-secret'});directLine.connectionStatus$.subscribe(value=>{console.log('Connection status:',value);});// Kick off connection.directLine.activity$.subscribe(()=>{});}catch(error){console.log('Never caught here, because the rejection is inside the subscription logic of activity$.');}setTimeout(()=>console.log('Exited peacefully.'),5000);
When DLJS failed to connect, it should handle all exceptions/rejections so the process can reach the "Exited peacefully" point.
However, today, because it does not handle rejection of connectWithRetryAsync. Thus, the "Exited peacefully" point was never reach. In the console:
Connection status: 0
Connection status: 1
Failed to connect Error: Unable to connect client to Node transport.
/workspaces/BotFramework-DirectLineJS/node_modules/botframework-streaming/lib/webSocket/nodeWebSocketClient.js:63
throw new Error('Unable to connect client to Node transport.');
^
Error: Unable to connect client to Node transport.
at WebSocketClient.<anonymous> (/workspaces/BotFramework-DirectLineJS/node_modules/botframework-streaming/lib/webSocket/nodeWebSocketClient.js:63:23)
at Generator.throw (<anonymous>)
at rejected (/workspaces/BotFramework-DirectLineJS/node_modules/botframework-streaming/lib/webSocket/nodeWebSocketClient.js:13:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.7.0
When it works, it should console out:
Connection status: 0
Connection status: 1
Failed to connect Error: Unable to connect client to Node transport.
Connection status: 4
Exited peacefully.
When subscribing
activity$
, it will callconnectWithRetryAsync()
, which is an async function of return typePromise<void>
.However, the
Promise
returned was never handled, i.e. nocatch()
or try-catch block.In Node.js, when a
Promise
reject without catching it and the control is back to the event-loop, Node.js will terminate the process immediately.Code snippet.
When DLJS failed to connect, it should handle all exceptions/rejections so the process can reach the "Exited peacefully" point.
However, today, because it does not handle rejection of
connectWithRetryAsync
. Thus, the "Exited peacefully" point was never reach. In the console:When it works, it should console out:
(
4
means failed to connect)(tagging @orgads)
The text was updated successfully, but these errors were encountered: