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:
James Russo
2026-09-01 21:35:40 -04:00
committed by GitHub
parent 305de15432
commit c0887b650d
12 changed files with 641 additions and 13 deletions
@@ -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([]);
+16 -1
View File
@@ -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, {