mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
94485: Fix initialization deadlock when backend is unavailable
When the REST server can't be found, `getEndpoint` errors out, no request gets sent, which causes `fetchRequest` to never emit. Because of this the `checkTokenCookie$` effect would get deadlocked and initialization would never complete.
This commit is contained in:
@@ -111,7 +111,6 @@ describe(`AuthRequestService`, () => {
|
||||
body: undefined,
|
||||
options,
|
||||
}));
|
||||
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -151,7 +150,6 @@ describe(`AuthRequestService`, () => {
|
||||
body: { content: 'something' },
|
||||
options,
|
||||
}));
|
||||
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -58,7 +58,9 @@ export abstract class AuthRequestService {
|
||||
public postToEndpoint(method: string, body?: any, options?: HttpOptions): Observable<RemoteData<AuthStatus>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
|
||||
this.halService.getEndpoint(this.linkName).pipe(
|
||||
const endpoint$ = this.halService.getEndpoint(this.linkName);
|
||||
|
||||
endpoint$.pipe(
|
||||
filter((href: string) => isNotEmpty(href)),
|
||||
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
|
||||
distinctUntilChanged(),
|
||||
@@ -68,7 +70,9 @@ export abstract class AuthRequestService {
|
||||
this.requestService.send(request);
|
||||
});
|
||||
|
||||
return this.fetchRequest(requestId);
|
||||
return endpoint$.pipe(
|
||||
switchMap(() => this.fetchRequest(requestId)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +83,9 @@ export abstract class AuthRequestService {
|
||||
public getRequest(method: string, options?: HttpOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<AuthStatus>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
|
||||
this.halService.getEndpoint(this.linkName).pipe(
|
||||
const endpoint$ = this.halService.getEndpoint(this.linkName);
|
||||
|
||||
endpoint$.pipe(
|
||||
filter((href: string) => isNotEmpty(href)),
|
||||
map((endpointURL) => this.getEndpointByMethod(endpointURL, method, ...linksToFollow)),
|
||||
distinctUntilChanged(),
|
||||
@@ -89,7 +95,9 @@ export abstract class AuthRequestService {
|
||||
this.requestService.send(request);
|
||||
});
|
||||
|
||||
return this.fetchRequest(requestId, ...linksToFollow);
|
||||
return endpoint$.pipe(
|
||||
switchMap(() => this.fetchRequest(requestId, ...linksToFollow)),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Factory function to create the request object to send. This needs to be a POST client side and
|
||||
|
Reference in New Issue
Block a user