Skip to content

Commit 6424784

Browse files
Added additional logging for catching permission errors.
1 parent 569f75c commit 6424784

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/Local.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,34 @@ function Local(){
3838
that.binaryPath = binaryPath;
3939
childProcess.exec('echo "" > ' + that.logfile);
4040

41+
try {
42+
if (!fs.existsSync(binaryPath)) {
43+
console.log("Binary does not exist at ", binaryPath);
44+
}
45+
} catch(err) {
46+
console.log("Failed to check the existence of Binary at ", binaryPath);
47+
console.error(err);
48+
}
49+
4150
that.opcode = 'start';
4251
that.tunnel = childProcess.execFile(that.binaryPath, that.getBinaryArgs(), function(error, stdout, stderr){
4352
if(error) {
4453
console.error('Error while trying to execute binary', error);
54+
console.error('STDOUT');
55+
console.error(stdout);
56+
console.error('STDERR');
57+
console.error(stderr);
58+
console.error('------')
4559
if(that.retriesLeft > 0) {
4660
console.log('Retrying Binary Download. Retries Left', that.retriesLeft);
4761
that.retriesLeft -= 1;
48-
fs.unlinkSync(that.binaryPath);
62+
try {
63+
fs.unlinkSync(that.binaryPath);
64+
} catch(err) {
65+
console.error('Failed to delete pre-existing binary: ');
66+
console.error(err);
67+
}
68+
4969
delete(that.binaryPath);
5070
that.start(options, callback);
5171
return;
@@ -191,8 +211,8 @@ function Local(){
191211
};
192212

193213
this.getBinaryPath = function(callback){
214+
this.binary = new LocalBinary();
194215
if(typeof(this.binaryPath) == 'undefined'){
195-
this.binary = new LocalBinary();
196216
var conf = {};
197217
if(this.proxyHost && this.proxyPort){
198218
conf.proxyHost = this.proxyHost;
@@ -201,6 +221,12 @@ function Local(){
201221
this.binary.binaryPath(conf, callback);
202222
} else {
203223
console.log('BINARY PATH IS DEFINED');
224+
if (this.checkPath(this.binaryPath, fs.X_OK)) {
225+
console.log('Binary has the correct permissions.');
226+
} else {
227+
console.log('Binary has incorrect permissions.');
228+
}
229+
204230
callback(this.binaryPath);
205231
}
206232
};

lib/LocalBinary.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function LocalBinary(){
7171
});
7272
}
7373

74+
console.log("Started Binary Download");
7475
https.get(options, function (response) {
7576
response.pipe(fileStream);
7677
response.on('error', function(err) {
@@ -97,6 +98,7 @@ function LocalBinary(){
9798
var destBinaryName = (this.windows) ? 'BrowserStackLocal.exe' : 'BrowserStackLocal';
9899
var binaryPath = path.join(destParentDir, destBinaryName);
99100
if(this.checkPath(binaryPath, fs.X_OK)){
101+
console.log("Binary found (with RWX flags) at ", binaryPath);
100102
callback(binaryPath);
101103
} else {
102104
this.download(conf, destParentDir, callback, 5);

0 commit comments

Comments
 (0)