|
|
@@ -62,7 +62,7 @@ export class ApiService {
|
|
|
},
|
|
|
});
|
|
|
const requestTimeout = action === 'reading/ai' ? 130_000 : action === 'app_word_audio_ensure' ? 60_000 : 20_000;
|
|
|
- const execute = () => this.resilient<T>(request.pipe(timeout({first:requestTimeout,with:()=>throwError(()=>new ApiError(this.isReadAction(action)?'请求暂未完成,请刷新重试。':'请求暂未完成,结果待核对;请刷新核对后重试,已填写内容会保留。'))})), sessionToken.startsWith('r:') || requiresCloudSession(action, params), this.isReadAction(action), sessionToken).pipe(tap(() => {
|
|
|
+ const execute = () => this.resilient<T>(request.pipe(timeout({first:requestTimeout,with:()=>throwError(()=>new ApiError(this.isReadAction(action)?'请求暂未完成,请刷新重试。':'请求暂未完成,结果待核对;请刷新核对后重试,已填写内容会保留。'))})), sessionToken.startsWith('r:') || requiresCloudSession(action, params), this.isReadAction(action), sessionToken, action).pipe(tap(() => {
|
|
|
if (!this.isReadAction(action) && action !== 'app_word_audio_ensure') {
|
|
|
this.invalidateOverviews();
|
|
|
this.announceDataChange();
|
|
|
@@ -134,13 +134,16 @@ export class ApiService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private resilient<T>(request: Observable<unknown>, authenticatedRequest = false, retryRead = true, requestToken = ''): Observable<ApiEnvelope<T>> {
|
|
|
+ private resilient<T>(request: Observable<unknown>, authenticatedRequest = false, retryRead = true, requestToken = '', action = ''): Observable<ApiEnvelope<T>> {
|
|
|
return request.pipe(
|
|
|
retry({
|
|
|
count: retryRead ? 1 : 0,
|
|
|
delay: error => {
|
|
|
+ const readingRead = ['reading/me', 'reading/query', 'reading/get', 'app_reading_source'].includes(action);
|
|
|
const gatewayBusy = error instanceof HttpErrorResponse && authenticatedRequest
|
|
|
- && isTransientGatewayReadError(error.status, error.error);
|
|
|
+ && (isTransientGatewayReadError(error.status, error.error)
|
|
|
+ || (readingRead && error.status === 500 && error.error?.retcode === -1
|
|
|
+ && error.error?.retmsg === '云函数执行失败'));
|
|
|
if (!this.isTransientError(error) && !gatewayBusy) return throwError(() => error);
|
|
|
const suggested = Number(error.error?.retryAfterMs) || 0;
|
|
|
const delayMs = Math.max(gatewayBusy ? 1200 : 300, Math.min(10000, suggested));
|