Skip to content

Commit 01a7f44

Browse files
committed
Wait for end of copy until spawning tunnel
Fixes the 'spawn ETXTBSY' errors as reported in browserstack#209. The patch is inspired from browserstack/browserstack-local-nodejs#19 (comment).
1 parent 52b23f0 commit 01a7f44

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/local.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, config, callback) {
185185
function(response) {
186186
response.pipe(file);
187187

188-
response.on('end', function() {
188+
file.on('close', function() {
189189
fs.chmodSync(localBinary, 0700);
190-
setTimeout(function() {
191-
tunnelLauncher();
192-
}, 100);
193-
}).on('error', function(e) {
190+
tunnelLauncher();
191+
});
192+
193+
response.on('error', function(e) {
194194
logger.info('Got error while downloading binary: ' + e.message);
195195
throw new Error('Got error while downloading binary: ' + e.message);
196196
});

0 commit comments

Comments
 (0)