Recover failed conversion workers and validate Nitro downloads correctly
This commit is contained in:
1 parent
a78d8256e0
commit
7880d5d5df
5 files changed
+91
-8
No files matched your search
@@ -154,8 +154,10 @@ export async function convertSwfToNitroAsync(
|
||||
buffer: Buffer,
|
||||
classname: string,
|
||||
): Promise<ConversionResult> {
|
||||
const res = await run({ type: "convert", buffer, classname });
|
||||
if (res.ok && res.result) return res.result;
|
||||
const res = await run({ type: "convert", buffer, classname }).catch(
|
||||
() => null,
|
||||
);
|
||||
if (res?.ok && res.result) return res.result;
|
||||
// Worker failed for this item — fall back to the main thread.
|
||||
return convertSwfToNitro(buffer, classname);
|
||||
}
|
||||
@@ -164,7 +166,7 @@ export async function extractIconFromSwfAsync(
|
||||
buffer: Buffer,
|
||||
classname: string,
|
||||
): Promise<Buffer | null> {
|
||||
const res = await run({ type: "icon", buffer, classname });
|
||||
if (res.ok) return res.icon ?? null;
|
||||
const res = await run({ type: "icon", buffer, classname }).catch(() => null);
|
||||
if (res?.ok) return res.icon ?? null;
|
||||
return extractIconFromSwf(buffer, classname);
|
||||
}
|
||||
Reference in new issue
Block a user