File tree 1 file changed +7
-5
lines changed
src/SignalR/clients/ts/signalr/src
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -185,14 +185,14 @@ export class HubConnection {
185
185
document . addEventListener ( "freeze" , this . _freezeEventListener ) ;
186
186
}
187
187
188
- const promise = new Promise ( ( res ) => {
189
- this . _lockResolver = res ;
190
- } ) ;
191
-
192
188
// Chrome and Edge currently support Web Locks, it's also experimental, so let's be safe and check if the APIs exist
193
189
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_API
194
190
// This should prevent the browsers from sleeping the tab which would close the connection unexpectedly
195
191
if ( navigator && ( navigator as any ) . locks && ( navigator as any ) . locks . request ) {
192
+ const promise = new Promise ( ( res ) => {
193
+ this . _lockResolver = res ;
194
+ } ) ;
195
+
196
196
// Use a 'shared' lock so multiple tabs to the same site can used the same lock
197
197
( navigator as any ) . locks . request ( 'signalr_client_lock' , { mode : "shared" } , ( ) => {
198
198
// Keep lock until promise is resolved
@@ -748,8 +748,10 @@ export class HubConnection {
748
748
this . _connectionState = HubConnectionState . Disconnected ;
749
749
this . _connectionStarted = false ;
750
750
751
- this . _lockResolver ( ) ;
752
751
if ( Platform . isBrowser ) {
752
+ if ( this . _lockResolver ) {
753
+ this . _lockResolver ( ) ;
754
+ }
753
755
if ( document ) {
754
756
document . removeEventListener ( "freeze" , this . _freezeEventListener ) ;
755
757
}
You can’t perform that action at this time.
0 commit comments