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,
|
body: undefined,
|
||||||
options,
|
options,
|
||||||
}));
|
}));
|
||||||
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -151,7 +150,6 @@ describe(`AuthRequestService`, () => {
|
|||||||
body: { content: 'something' },
|
body: { content: 'something' },
|
||||||
options,
|
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>> {
|
public postToEndpoint(method: string, body?: any, options?: HttpOptions): Observable<RemoteData<AuthStatus>> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
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)),
|
filter((href: string) => isNotEmpty(href)),
|
||||||
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
|
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
@@ -68,7 +70,9 @@ export abstract class AuthRequestService {
|
|||||||
this.requestService.send(request);
|
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>> {
|
public getRequest(method: string, options?: HttpOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<AuthStatus>> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
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)),
|
filter((href: string) => isNotEmpty(href)),
|
||||||
map((endpointURL) => this.getEndpointByMethod(endpointURL, method, ...linksToFollow)),
|
map((endpointURL) => this.getEndpointByMethod(endpointURL, method, ...linksToFollow)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
@@ -89,7 +95,9 @@ export abstract class AuthRequestService {
|
|||||||
this.requestService.send(request);
|
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
|
* 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