Skip to content

Commit 3a8aaf0

Browse files
author
antelle
committed
retrying on busy files
1 parent 8f14144 commit 3a8aaf0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

patch.test.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22
const http = require('http');
3-
const { spawn, spawnSync } = require('child_process');
3+
const { spawn } = require('child_process');
44

55
const makeTestPackage = require('./make-test-package');
66

@@ -16,7 +16,8 @@ const Timeouts = {
1616
PollInterval: 100,
1717
BeforeSendingSigUsr1: 2000,
1818
DebuggerConnect: 3000,
19-
SelfExit: 6000
19+
SelfExit: 6000,
20+
FileIsBusyRetry: 1000
2021
};
2122

2223
let env;
@@ -152,8 +153,17 @@ describe('patch', () => {
152153
default:
153154
throw new Error(`Platform ${process.platform} is not supported`);
154155
}
155-
console.log('processes', spawnSync('ps', ['ax']).stdout.toString('utf8'));
156-
return patch({ path: packagePath });
156+
for (let i = 0; i < 10; i++) {
157+
try {
158+
return patch({ path: packagePath });
159+
} catch (ex) {
160+
if (ex.toString().includes('text file is busy')) {
161+
await sleep(Timeouts.FileIsBusyRetry);
162+
continue;
163+
}
164+
throw ex;
165+
}
166+
}
157167
});
158168

159169
test('no args', async () => {

0 commit comments

Comments
 (0)