Skip to content

Commit

Permalink
Sm/retry-more-mdpai-errors (#792)
Browse files Browse the repository at this point in the history
* fix: tolerate 2 new mdapi faults

* chore: auto-update metadata coverage in METADATA_SUPPORT.md

* test: record perf

Co-authored-by: svc-cli-bot <[email protected]>
  • Loading branch information
mshanemc and svc-cli-bot authored Dec 13, 2022
1 parent 28af4b8 commit ffa7407
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
11 changes: 8 additions & 3 deletions src/client/metadataTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ export abstract class MetadataTransfer<Status extends MetadataRequestStatus, Res
}
// tolerate intermittent network errors upto retry limit
if (
['ETIMEDOUT', 'ENOTFOUND', 'ECONNRESET', 'socket hang up'].some((retryableNetworkError) =>
(e as Error).message.includes(retryableNetworkError)
)
[
'ETIMEDOUT',
'ENOTFOUND',
'ECONNRESET',
'socket hang up',
'INVALID_QUERY_LOCATOR',
'<h1>Bad Message 400</h1><pre>reason: Bad Request</pre>',
].some((retryableNetworkError) => (e as Error).message.includes(retryableNetworkError))
) {
this.logger.debug('Network error on the request', e);
await Lifecycle.getInstance().emitWarning('Network error occurred. Continuing to poll.');
Expand Down
22 changes: 22 additions & 0 deletions test/client/metadataTransfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,28 @@ describe('MetadataTransfer', () => {
expect(checkStatus.callCount).to.equal(3);
});

it('should tolerate 2 known mdapi errors', async () => {
const { checkStatus } = operation.lifecycle;
checkStatus.onFirstCall().throws(new Error('<h1>Bad Message 400</h1><pre>reason: Bad Request</pre>'));
checkStatus.onSecondCall().throws(new Error('INVALID_QUERY_LOCATOR'));
checkStatus.onThirdCall().resolves({ done: true });

await operation.pollStatus();
expect(checkStatus.callCount).to.equal(3);
});

it('should tolerate known mdapi error', async () => {
const { checkStatus } = operation.lifecycle;
const networkError1 = new Error('foo');
networkError1.name = 'JsonParseError';
checkStatus.onFirstCall().throws(networkError1);
checkStatus.onSecondCall().throws(networkError1);
checkStatus.onThirdCall().resolves({ done: true });

await operation.pollStatus();
expect(checkStatus.callCount).to.equal(3);
});

it('should throw wrapped error if there are no error listeners', async () => {
const { checkStatus } = operation.lifecycle;
const originalError = new Error('whoops');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 206.5693120000069
"duration": 200.72280899999896
},
{
"name": "sourceToMdapi",
"duration": 4943.071838999982
"duration": 4991.547512999998
},
{
"name": "sourceToZip",
"duration": 4826.46210199999
"duration": 5128.423543000012
},
{
"name": "mdapiToSource",
"duration": 3256.713862000004
"duration": 3427.0605170000053
}
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 384.5527920000022
"duration": 423.05887099998654
},
{
"name": "sourceToMdapi",
"duration": 6970.504320000007
"duration": 7163.629501999996
},
{
"name": "sourceToZip",
"duration": 6130.4723740000045
"duration": 7302.745194999996
},
{
"name": "mdapiToSource",
"duration": 4920.01653100003
"duration": 4091.7455520000076
}
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 681.8188979999977
"duration": 664.222689999995
},
{
"name": "sourceToMdapi",
"duration": 10472.678083999956
"duration": 11668.923317000008
},
{
"name": "sourceToZip",
"duration": 8984.845709999965
"duration": 9924.087503000017
},
{
"name": "mdapiToSource",
"duration": 10057.14215899998
"duration": 8384.765007000009
}
]

0 comments on commit ffa7407

Please sign in to comment.