Skip to content

Commit

Permalink
fix: avoid crashing extension in Chrome
Browse files Browse the repository at this point in the history
More context: #464
  • Loading branch information
lidel committed May 23, 2018
1 parent 9fbe63f commit cda171e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions add-on/src/popup/quick-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ function quickUploadStore (state, emitter) {
})
totalSize += file.size
}
if (!browser.runtime.id.includes('@')) {
// we are in non-Firefox runtime (we know for a fact that Chrome puts no @ in id)
if (state.ipfsNodeType === 'external' && totalSize >= 134217728) {
// avoid crashing Chrome until the source of issue is fixed in js-ipfs-api
// - https://github.com/ipfs-shipyard/ipfs-companion/issues/464
// - https://github.com/ipfs/js-ipfs-api/issues/654
throw new Error('Unable to process payload bigger than 128MiB in Chrome. See: js-ipfs-api/issues/654')
}
}
progressHandler(0, totalSize, state, emitter)
emitter.emit('render')
// TODO: update flag below after wrapping support is released with new js-ipfs
Expand All @@ -103,8 +112,8 @@ function quickUploadStore (state, emitter) {
} catch (err) {
console.error('Unable to perform quick upload', err)
// keep upload tab and display error message in it
state.message = `Unable to upload to IPFS API: ${err.name ? err.name : err}`
state.progress = ''
state.message = `Unable to upload to IPFS API:`
state.progress = `${err}`
emitter.emit('render')
}
})
Expand Down

0 comments on commit cda171e

Please sign in to comment.