mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 02:36:10 +00:00
fix(producer): transport safe extraction failure metadata (#3592)
* fix(producer): transport safe extraction failure metadata * refactor(producer): generalize public error metadata * test(producer): use vendor-neutral media hosts
This commit is contained in:
@@ -447,6 +447,7 @@ describe("downloadToTemp atomic publication and bounded retry", () => {
|
||||
).rejects.toMatchObject({
|
||||
kind: "length_mismatch",
|
||||
retryable: true,
|
||||
telemetry: expect.objectContaining({ attempt: 2 }),
|
||||
} satisfies Partial<UrlDownloadError>);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
expect(readdirSync(dir).filter((name) => name.startsWith("download_"))).toEqual([]);
|
||||
@@ -802,6 +803,7 @@ describe("downloadToTemp atomic publication and bounded retry", () => {
|
||||
).rejects.toMatchObject({
|
||||
kind: "invalid_payload",
|
||||
retryable: false,
|
||||
telemetry: expect.objectContaining({ attempt: 1 }),
|
||||
} satisfies Partial<UrlDownloadError>);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(temporaryDownloadEntries(dir)).toEqual([]);
|
||||
|
||||
@@ -1113,7 +1113,22 @@ async function downloadWithRetry(
|
||||
return await runDownloadAttempt(url, localPath, timeoutMs, attempt + 1, options, signal);
|
||||
} catch (error) {
|
||||
const classified = classifyDownloadFailure(error);
|
||||
if (!classified.locallyRetryable || attempt >= maxTransientRetries) throw classified;
|
||||
if (!classified.locallyRetryable || attempt >= maxTransientRetries) {
|
||||
const identity = safeDownloadUrlIdentity(url);
|
||||
throw new UrlDownloadError(
|
||||
classified.kind,
|
||||
classified.retryable,
|
||||
classified.message,
|
||||
classified.status,
|
||||
{
|
||||
...classified.telemetry,
|
||||
urlFingerprint: identity.urlFingerprint,
|
||||
initialHost: identity.host,
|
||||
attempt: attempt + 1,
|
||||
},
|
||||
classified.locallyRetryable,
|
||||
);
|
||||
}
|
||||
if (classified.retryable) onTransientRetry?.(classified);
|
||||
const identity = safeDownloadUrlIdentity(url);
|
||||
emitDownloadTelemetry(options, {
|
||||
|
||||
Reference in New Issue
Block a user