Skip to content

Commit

Permalink
feat(vhd-lib): retry on remote internal error when writing a chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Jan 11, 2022
1 parent 902abd5 commit 8325c61
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vhd-lib/Vhd/VhdDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { test, set: setBitmap } = require('../_bitmap')
const { VhdAbstract } = require('./VhdAbstract')
const assert = require('assert')
const promisify = require('promise-toolbox/promisify')
const pRetry = require('promise-toolbox/retry.js')
const zlib = require('zlib')

const { debug } = createLogger('vhd-lib:VhdDirectory')
Expand Down Expand Up @@ -162,7 +163,13 @@ exports.VhdDirectory = class VhdDirectory extends VhdAbstract {
)

const compressed = await this.#compressor.compress(buffer)
return this._handler.outputFile(this._getChunkPath(partName), compressed, this._opts)
return pRetry(async () => this._handler.outputFile(this._getChunkPath(partName), compressed, this._opts), {
tries: 5,
when: e => e.code === 'InternalError',
onRetry: () => {
warn('retrying writechunk')
},
})
}

// put block in subdirectories to limit impact when doing directory listing
Expand Down

0 comments on commit 8325c61

Please sign in to comment.