Updated terminal flow, to check for promise completion
Bryan Roe committed
May 19, 2020 at 01:21 UTC
52487cd4bfef3afe6e0c5ae3466f9e0b770b94e7
1 file changed
+18
-2
agents/meshcore.js
+18
-2
@@ -1185,6 +1185,8 @@ function createMeshCore(agent) {
1185
this.end = function ()
1186
{
1187
if (this.httprequest.tpromise._consent) { this.httprequest.tpromise._consent.close(); }
1188
+ if (this.httprequest.connectionPromise) { this.httprequest.connectionPromise._rej('Closed'); }
1189
+
1190
// Remove the terminal session to the count to update the server
1191
if (this.httprequest.userid != null)
1192
{
@@ -1272,7 +1274,14 @@ function createMeshCore(agent) {
1274
this.httprequest._dispatcher.httprequest = this.httprequest;
1275
this.httprequest._dispatcher.on('connection', function (c)
1276
{
1275
- this.httprequest.connectionPromise._res(c);
1277
+ if (this.httprequest.connectionPromise.completed)
1278
+ {
1279
+ c.end();
1280
+ }
1281
+ else
1282
+ {
1283
+ this.httprequest.connectionPromise._res(c);
1284
+ }
1285
});
1286
}
1287
else
@@ -1305,7 +1314,14 @@ function createMeshCore(agent) {
1314
that.httprequest._dispatcher.ws = that;
1315
that.httprequest._dispatcher.on('connection', function (c)
1316
{
1308
- this.ws.httprequest.connectionPromise._res(c);
1317
+ if (this.ws.httprequest.connectionPromise.completed)
1318
+ {
1319
+ c.end();
1320
+ }
1321
+ else
1322
+ {
1323
+ this.ws.httprequest.connectionPromise._res(c);
1324
+ }
1325
});
1326
}
1327
});