@microsoft/signalr
Advanced tools
Comparing version
@@ -60,2 +60,3 @@ "use strict"; | ||
if (options === void 0) { options = {}; } | ||
this.stopPromiseResolver = function () { }; | ||
this.features = {}; | ||
@@ -227,3 +228,2 @@ this.negotiateVersion = 1; | ||
this.logger.log(ILogger_1.LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."); | ||
this.stopConnection(); | ||
_a.label = 10; | ||
@@ -325,2 +325,4 @@ case 10: return [2 /*return*/]; | ||
this.transport = undefined; | ||
// if start fails, any active calls to stop assume that start will complete the stop promise | ||
this.stopPromiseResolver(); | ||
return [2 /*return*/, Promise.reject(e_3)]; | ||
@@ -327,0 +329,0 @@ case 13: return [2 /*return*/]; |
@@ -65,2 +65,3 @@ "use strict"; | ||
var _this = this; | ||
this.nextKeepAlive = 0; | ||
Utils_1.Arg.isRequired(connection, "connection"); | ||
@@ -580,30 +581,9 @@ Utils_1.Arg.isRequired(logger, "logger"); | ||
HubConnection.prototype.resetKeepAliveInterval = function () { | ||
var _this = this; | ||
if (this.connection.features.inherentKeepAlive) { | ||
return; | ||
} | ||
// Set the time we want the next keep alive to be sent | ||
// Timer will be setup on next message receive | ||
this.nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds; | ||
this.cleanupPingTimer(); | ||
this.pingServerHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.connectionState === HubConnectionState.Connected)) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.sendMessage(this.cachedPingMessage)]; | ||
case 2: | ||
_b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a = _b.sent(); | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, this.keepAliveIntervalInMilliseconds); | ||
}; | ||
@@ -615,2 +595,33 @@ HubConnection.prototype.resetTimeoutPeriod = function () { | ||
this.timeoutHandle = setTimeout(function () { return _this.serverTimeout(); }, this.serverTimeoutInMilliseconds); | ||
// Set keepAlive timer if there isn't one | ||
if (this.pingServerHandle === undefined) { | ||
var nextPing = this.nextKeepAlive - new Date().getTime(); | ||
if (nextPing < 0) { | ||
nextPing = 0; | ||
} | ||
// The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute | ||
this.pingServerHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.connectionState === HubConnectionState.Connected)) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.sendMessage(this.cachedPingMessage)]; | ||
case 2: | ||
_b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a = _b.sent(); | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, nextPing); | ||
} | ||
} | ||
@@ -758,3 +769,7 @@ }; | ||
if (this.connectionState !== HubConnectionState.Reconnecting) { | ||
this.logger.log(ILogger_1.LogLevel.Debug, "Connection left the reconnecting state during reconnect attempt. Done reconnecting."); | ||
this.logger.log(ILogger_1.LogLevel.Debug, "Connection moved to the '" + this.connectionState + "' from the reconnecting state during reconnect attempt. Done reconnecting."); | ||
// The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong. | ||
if (this.connectionState === HubConnectionState.Disconnecting) { | ||
this.completeClose(); | ||
} | ||
return [2 /*return*/]; | ||
@@ -799,2 +814,3 @@ } | ||
clearTimeout(this.pingServerHandle); | ||
this.pingServerHandle = undefined; | ||
} | ||
@@ -801,0 +817,0 @@ }; |
@@ -52,3 +52,3 @@ "use strict"; | ||
/** The version of the SignalR client. */ | ||
exports.VERSION = "5.0.5"; | ||
exports.VERSION = "5.0.6"; | ||
/** @private */ | ||
@@ -55,0 +55,0 @@ var Arg = /** @class */ (function () { |
@@ -58,2 +58,3 @@ // Copyright (c) .NET Foundation. All rights reserved. | ||
if (options === void 0) { options = {}; } | ||
this.stopPromiseResolver = function () { }; | ||
this.features = {}; | ||
@@ -225,3 +226,2 @@ this.negotiateVersion = 1; | ||
this.logger.log(LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."); | ||
this.stopConnection(); | ||
_a.label = 10; | ||
@@ -323,2 +323,4 @@ case 10: return [2 /*return*/]; | ||
this.transport = undefined; | ||
// if start fails, any active calls to stop assume that start will complete the stop promise | ||
this.stopPromiseResolver(); | ||
return [2 /*return*/, Promise.reject(e_3)]; | ||
@@ -325,0 +327,0 @@ case 13: return [2 /*return*/]; |
@@ -37,2 +37,3 @@ import { IStreamResult } from "./Stream"; | ||
private stopPromise?; | ||
private nextKeepAlive; | ||
private reconnectDelayHandle?; | ||
@@ -51,2 +52,4 @@ private timeoutHandle?; | ||
* Allows the server to detect hard disconnects (like when a client unplugs their computer). | ||
* The ping will happen at most as often as the server pings. | ||
* If the server pings every 5 seconds, a value lower than 5 will ping every 5 seconds. | ||
*/ | ||
@@ -53,0 +56,0 @@ keepAliveIntervalInMilliseconds: number; |
@@ -63,2 +63,3 @@ // Copyright (c) .NET Foundation. All rights reserved. | ||
var _this = this; | ||
this.nextKeepAlive = 0; | ||
Arg.isRequired(connection, "connection"); | ||
@@ -578,30 +579,9 @@ Arg.isRequired(logger, "logger"); | ||
HubConnection.prototype.resetKeepAliveInterval = function () { | ||
var _this = this; | ||
if (this.connection.features.inherentKeepAlive) { | ||
return; | ||
} | ||
// Set the time we want the next keep alive to be sent | ||
// Timer will be setup on next message receive | ||
this.nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds; | ||
this.cleanupPingTimer(); | ||
this.pingServerHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.connectionState === HubConnectionState.Connected)) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.sendMessage(this.cachedPingMessage)]; | ||
case 2: | ||
_b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a = _b.sent(); | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, this.keepAliveIntervalInMilliseconds); | ||
}; | ||
@@ -613,2 +593,33 @@ HubConnection.prototype.resetTimeoutPeriod = function () { | ||
this.timeoutHandle = setTimeout(function () { return _this.serverTimeout(); }, this.serverTimeoutInMilliseconds); | ||
// Set keepAlive timer if there isn't one | ||
if (this.pingServerHandle === undefined) { | ||
var nextPing = this.nextKeepAlive - new Date().getTime(); | ||
if (nextPing < 0) { | ||
nextPing = 0; | ||
} | ||
// The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute | ||
this.pingServerHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(this.connectionState === HubConnectionState.Connected)) return [3 /*break*/, 4]; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.sendMessage(this.cachedPingMessage)]; | ||
case 2: | ||
_b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a = _b.sent(); | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, nextPing); | ||
} | ||
} | ||
@@ -756,3 +767,7 @@ }; | ||
if (this.connectionState !== HubConnectionState.Reconnecting) { | ||
this.logger.log(LogLevel.Debug, "Connection left the reconnecting state during reconnect attempt. Done reconnecting."); | ||
this.logger.log(LogLevel.Debug, "Connection moved to the '" + this.connectionState + "' from the reconnecting state during reconnect attempt. Done reconnecting."); | ||
// The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong. | ||
if (this.connectionState === HubConnectionState.Disconnecting) { | ||
this.completeClose(); | ||
} | ||
return [2 /*return*/]; | ||
@@ -797,2 +812,3 @@ } | ||
clearTimeout(this.pingServerHandle); | ||
this.pingServerHandle = undefined; | ||
} | ||
@@ -799,0 +815,0 @@ }; |
@@ -50,3 +50,3 @@ // Copyright (c) .NET Foundation. All rights reserved. | ||
/** The version of the SignalR client. */ | ||
export var VERSION = "5.0.5"; | ||
export var VERSION = "5.0.6"; | ||
/** @private */ | ||
@@ -53,0 +53,0 @@ var Arg = /** @class */ (function () { |
{ | ||
"name": "@microsoft/signalr", | ||
"version": "5.0.5", | ||
"version": "5.0.6", | ||
"description": "ASP.NET Core SignalR Client", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -54,3 +54,3 @@ // Copyright (c) .NET Foundation. All rights reserved. | ||
private stopPromise?: Promise<void>; | ||
private stopPromiseResolver!: (value?: PromiseLike<void>) => void; | ||
private stopPromiseResolver: (value?: PromiseLike<void>) => void = () => {}; | ||
private stopError?: Error; | ||
@@ -218,3 +218,2 @@ private accessTokenFactory?: () => string | Promise<string>; | ||
this.logger.log(LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."); | ||
this.stopConnection(); | ||
} | ||
@@ -299,2 +298,5 @@ } | ||
this.transport = undefined; | ||
// if start fails, any active calls to stop assume that start will complete the stop promise | ||
this.stopPromiseResolver(); | ||
return Promise.reject(e); | ||
@@ -301,0 +303,0 @@ } |
@@ -57,2 +57,3 @@ // Copyright (c) .NET Foundation. All rights reserved. | ||
private stopPromise?: Promise<void>; | ||
private nextKeepAlive: number = 0; | ||
@@ -77,2 +78,4 @@ // The type of these a) doesn't matter and b) varies when building in browser and node contexts | ||
* Allows the server to detect hard disconnects (like when a client unplugs their computer). | ||
* The ping will happen at most as often as the server pings. | ||
* If the server pings every 5 seconds, a value lower than 5 will ping every 5 seconds. | ||
*/ | ||
@@ -608,14 +611,7 @@ public keepAliveIntervalInMilliseconds: number; | ||
// Set the time we want the next keep alive to be sent | ||
// Timer will be setup on next message receive | ||
this.nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds; | ||
this.cleanupPingTimer(); | ||
this.pingServerHandle = setTimeout(async () => { | ||
if (this.connectionState === HubConnectionState.Connected) { | ||
try { | ||
await this.sendMessage(this.cachedPingMessage); | ||
} catch { | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
} | ||
} | ||
}, this.keepAliveIntervalInMilliseconds); | ||
} | ||
@@ -627,2 +623,23 @@ | ||
this.timeoutHandle = setTimeout(() => this.serverTimeout(), this.serverTimeoutInMilliseconds); | ||
// Set keepAlive timer if there isn't one | ||
if (this.pingServerHandle === undefined) { | ||
let nextPing = this.nextKeepAlive - new Date().getTime(); | ||
if (nextPing < 0) { | ||
nextPing = 0; | ||
} | ||
// The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute | ||
this.pingServerHandle = setTimeout(async () => { | ||
if (this.connectionState === HubConnectionState.Connected) { | ||
try { | ||
await this.sendMessage(this.cachedPingMessage); | ||
} catch { | ||
// We don't care about the error. It should be seen elsewhere in the client. | ||
// The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering | ||
this.cleanupPingTimer(); | ||
} | ||
} | ||
}, nextPing); | ||
} | ||
} | ||
@@ -773,3 +790,7 @@ } | ||
if (this.connectionState !== HubConnectionState.Reconnecting) { | ||
this.logger.log(LogLevel.Debug, "Connection left the reconnecting state during reconnect attempt. Done reconnecting."); | ||
this.logger.log(LogLevel.Debug, `Connection moved to the '${this.connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`); | ||
// The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong. | ||
if (this.connectionState as any === HubConnectionState.Disconnecting) { | ||
this.completeClose(); | ||
} | ||
return; | ||
@@ -815,2 +836,3 @@ } | ||
clearTimeout(this.pingServerHandle); | ||
this.pingServerHandle = undefined; | ||
} | ||
@@ -817,0 +839,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2678446
0.63%22653
0.44%