[core] GOWS - fix document media — 403 on live media + media-retry never completes/refreshes directPath - fix ##2131
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / GOWS - none - amd64 - gows (push) Waiting to run
Release / GOWS - none - linux/arm64 - gows-arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run
Release / WEBJS - chrome - amd64 - chrome (push) Waiting to run
Release / WEBJS - chromium - amd64 - latest (push) Waiting to run
Release / WEBJS - chromium - linux/arm64 - arm (push) Waiting to run
Release / GOWS - none - amd64 - gows (push) Waiting to run
Release / GOWS - none - linux/arm64 - gows-arm (push) Waiting to run
Release / NOWEB - none - amd64 - noweb (push) Waiting to run
Release / NOWEB - none - linux/arm64 - noweb-arm (push) Waiting to run
This commit is contained in:
1 parent
a9ff7d763d
commit
208f4f3d78
2 files changed
+27
-1
No files matched your search
@@ -2958,6 +2958,19 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gRPC status codes returned by GOWS DownloadMedia that represent a definitive
|
||||
* failure (the media cannot be fetched right now and retrying won't help). Used
|
||||
* to tag the error as non-retriable so MediaManager doesn't re-issue the call.
|
||||
*/
|
||||
const NON_RETRIABLE_DOWNLOAD_MEDIA_CODES: Set<number> = new Set([
|
||||
grpc.status.FAILED_PRECONDITION,
|
||||
grpc.status.NOT_FOUND,
|
||||
grpc.status.INVALID_ARGUMENT,
|
||||
grpc.status.PERMISSION_DENIED,
|
||||
grpc.status.UNIMPLEMENTED,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Many encrypted stickers carry URL "https://a.whatsapp.net" with no path. If
|
||||
* that string is passed to DownloadMedia, the Go client may attempt HTTP GET to
|
||||
@@ -3062,6 +3075,12 @@ export class GOWSEngineMediaProcessor implements IMediaEngineProcessor<any> {
|
||||
} catch (err) {
|
||||
if (err?.code === grpc.status.DEADLINE_EXCEEDED) {
|
||||
err.message = `DownloadMedia timed out after ${mediaDownloadTimeoutMs}ms for message '${message?.Info?.ID}'`;
|
||||
} else if (NON_RETRIABLE_DOWNLOAD_MEDIA_CODES.has(err?.code)) {
|
||||
// The media is not currently downloadable (e.g. CDN 403 after the
|
||||
// anonymous + media-retry fallbacks, or the object is gone). Retrying
|
||||
// the gRPC call won't help and each attempt can block on a media-retry
|
||||
// wait, so mark it so MediaManager stops retrying.
|
||||
err.nonRetriable = true;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,14 @@ export class MediaManager implements IMediaManager {
|
||||
const retryOptions = this.RETRY_OPTIONS;
|
||||
try {
|
||||
return await promiseRetry((retry: CallableFunction, number: number) => {
|
||||
return fn().catch(retry);
|
||||
return fn().catch((err: any) => {
|
||||
// Some failures are definitive (e.g. media not downloadable): retrying
|
||||
// won't help and may block, so abort the retry loop immediately.
|
||||
if (err?.nonRetriable) {
|
||||
throw err;
|
||||
}
|
||||
return retry(err);
|
||||
});
|
||||
}, retryOptions);
|
||||
} catch (error) {
|
||||
this.log.error(
|
||||
|
||||
Reference in new issue
Block a user