diff --git a/packages/cli/bin/run.cmd b/packages/cli/bin/run.cmd old mode 100644 new mode 100755 diff --git a/packages/cli/src/compiler/index.ts b/packages/cli/src/compiler/index.ts index 143b5f7e3..2ab638d48 100644 --- a/packages/cli/src/compiler/index.ts +++ b/packages/cli/src/compiler/index.ts @@ -796,21 +796,26 @@ export default class Compiler { } async _uploadToIPFS(file: { path: string; content: Buffer }) { - try { - const files = this.ipfs.addAll([file]); - - // We get back async iterable - const filesIterator = files[Symbol.asyncIterator](); - // We only care about the first item, since that is the file, rest could be directories - const { value } = await filesIterator.next(); - - // we grab the file and pin it - const uploadedFile = value as Awaited>; - await this.ipfs.pin.add(uploadedFile.cid); - - return uploadedFile.cid.toString(); - } catch (e) { - throw Error(`Failed to upload file to IPFS: ${e.message}`); + while (1) { + try { + const files = this.ipfs.addAll([file]); + + // We get back async iterable + const filesIterator = files[Symbol.asyncIterator](); + // We only care about the first item, since that is the file, rest could be directories + const { value } = await filesIterator.next(); + + // we grab the file and pin it + const uploadedFile = value as Awaited>; + + await this.ipfs.pin.add(uploadedFile.cid); + + return uploadedFile.cid.toString(); + } catch (e) { + console.log('Failed to upload file to IPFS: ', [(e as any).message]); + console.log('Retrying in 4 seconds...'); + await new Promise(resolve => setTimeout(resolve, 4_000)); + } } } }