Skip to content

Commit fb72e86

Browse files
committed
add recovery mechanism & delay client creation
1 parent c82ad47 commit fb72e86

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/unraid-api-plugin-connect/src/connection-status/cloud.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,14 @@ export class CloudService {
235235
* as an error.
236236
*/
237237
if (local !== network) {
238-
this.logger.verbose(
239-
`Local and network resolvers returned different IPs for "${hostname}". [local="${local}"] [network="${network}"]`
240-
);
238+
const error = `Local and network resolvers returned different IPs for "${hostname}". [local="${local ?? 'NOT FOUND'}"] [network="${
239+
network ?? 'NOT FOUND'
240+
}. Please refresh the page."]`;
241+
this.mothership.setConnectionStatus({
242+
status: MinigraphStatus.ERROR_RETRYING,
243+
error,
244+
});
245+
throw new Error(error);
241246
}
242247

243248
return { local, network };

packages/unraid-api-plugin-connect/src/mothership-proxy/graphql.client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
1+
import { Injectable, Logger, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
22
import { ConfigService } from '@nestjs/config';
33
import { EventEmitter2 } from '@nestjs/event-emitter';
44

@@ -27,7 +27,7 @@ const FIVE_MINUTES_MS = 5 * 60 * 1000;
2727
type Unsubscribe = () => void;
2828

2929
@Injectable()
30-
export class MothershipGraphqlClientService implements OnModuleInit, OnModuleDestroy {
30+
export class MothershipGraphqlClientService implements OnApplicationBootstrap, OnModuleDestroy {
3131
private logger = new Logger(MothershipGraphqlClientService.name);
3232
private apolloClient: ApolloClient<NormalizedCacheObject> | null = null;
3333
private wsClient: Client | null = null;
@@ -56,10 +56,10 @@ export class MothershipGraphqlClientService implements OnModuleInit, OnModuleDes
5656
/**
5757
* Initialize the GraphQL client when the module is created
5858
*/
59-
async onModuleInit(): Promise<void> {
60-
await this.createClientInstance();
59+
async onApplicationBootstrap(): Promise<void> {
6160
this.configService.getOrThrow('API_VERSION');
6261
this.configService.getOrThrow('MOTHERSHIP_GRAPHQL_LINK');
62+
await this.createClientInstance();
6363
}
6464

6565
/**

0 commit comments

Comments
 (0)