@@ -150,21 +150,25 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
150
150
useEffect ( ( ) => {
151
151
// Check connection status on initial page load
152
152
const apiClient = ServerConnections . currentApiClient ( ) ;
153
- const firstConnection = ServerConnections . firstConnection ;
154
- console . debug ( '[ConnectionRequired] connection state' , firstConnection ?. State ) ;
155
- ServerConnections . firstConnection = null ;
156
-
157
- if ( firstConnection && firstConnection . State !== ConnectionState . SignedIn && ! apiClient ?. isLoggedIn ( ) ) {
158
- handleIncompleteWizard ( firstConnection )
159
- . catch ( err => {
160
- console . error ( '[ConnectionRequired] could not start wizard' , err ) ;
161
- } ) ;
162
- } else {
163
- validateUserAccess ( )
164
- . catch ( err => {
165
- console . error ( '[ConnectionRequired] could not validate user access' , err ) ;
166
- } ) ;
167
- }
153
+ const connection = Promise . resolve ( ServerConnections . firstConnection ? null : ServerConnections . connect ( ) ) ;
154
+ connection . then ( firstConnection => {
155
+ console . debug ( '[ConnectionRequired] connection state' , firstConnection ?. State ) ;
156
+ ServerConnections . firstConnection = true ;
157
+
158
+ if ( firstConnection && firstConnection . State !== ConnectionState . SignedIn && ! apiClient ?. isLoggedIn ( ) ) {
159
+ handleIncompleteWizard ( firstConnection )
160
+ . catch ( err => {
161
+ console . error ( '[ConnectionRequired] could not start wizard' , err ) ;
162
+ } ) ;
163
+ } else {
164
+ validateUserAccess ( )
165
+ . catch ( err => {
166
+ console . error ( '[ConnectionRequired] could not validate user access' , err ) ;
167
+ } ) ;
168
+ }
169
+ } ) . catch ( err => {
170
+ console . error ( '[ConnectionRequired] failed to connect' , err ) ;
171
+ } ) ;
168
172
} , [ handleIncompleteWizard , validateUserAccess ] ) ;
169
173
170
174
if ( isLoading ) {
0 commit comments