Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit c1edc48

Browse files
committed
fix: try catch if ipfs upload failed
1 parent 0c75255 commit c1edc48

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

src/content-script/hooks/twitter.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,26 @@ class TwitterHook {
189189
duration: 0,
190190
});
191191

192-
const attachments = await Promise.all(
193-
Array.from(attachmentUrls).map(async (attachment) => {
194-
const result = await fetch(attachment);
195-
const blob = await result.blob();
196-
return {
197-
address: await upload(blob),
198-
mime_type: blob.type,
199-
size_in_bytes: blob.size,
200-
};
201-
}),
202-
);
192+
const attachments = (
193+
await Promise.all(
194+
Array.from(attachmentUrls).map(async (attachment) => {
195+
const result = await fetch(attachment);
196+
const blob = await result.blob();
197+
try {
198+
return {
199+
address: await upload(blob),
200+
mime_type: blob.type,
201+
size_in_bytes: blob.size,
202+
};
203+
} catch (e) {
204+
this.main.xlog('error', 'Failed to upload to IPFS with error: ', e);
205+
return {
206+
address: '',
207+
};
208+
}
209+
}),
210+
)
211+
).filter((attachment) => attachment.address !== '');
203212

204213
notice?.close();
205214

0 commit comments

Comments
 (0)