Skip to content

Commit

Permalink
Merge pull request #42 from DanielHaroldLane/master
Browse files Browse the repository at this point in the history
Fix Node 18 Unzip Issues
  • Loading branch information
Shivanshu-lambdatest authored Apr 20, 2023
2 parents 934ea2f + a275820 commit 513e5f5
Show file tree
Hide file tree
Showing 3 changed files with 1,640 additions and 831 deletions.
41 changes: 17 additions & 24 deletions lib/tunnel_binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var localTunnelConfig_ = require('./cfg/node-tunnel-config-v3-latest.json'),
urlParse = require('url'),
HttpsProxyAgent = require('https-proxy-agent'),
util = require('./util'),
unzip = require('unzipper'),
AdmZip = require('adm-zip'),
fs = require('fs'),
path = require('path'),
os = require('os'),
Expand Down Expand Up @@ -138,30 +138,23 @@ function TunnelBinary(httpTunnelConfig, options) {
var destBinaryPath = path.join(destParentDir, destBinaryName);
// Reading and Unzipping binary zip File
console.log(`Extracting binary`);
fs.createReadStream(binaryPath)
.pipe(unzip.Extract({ path: destParentDir }))
.on('error', function(e) {
console.log("Error log ------> ", e);
logger.log(
conf['user'],
conf['key'],
{ filename: __filename },
conf,
'Got Error while unzip downloading binary' + e
);
self.retryBinaryDownload_(conf, destParentDir, retries, binaryPath, fnCallback);
})
.on('close', function() {
// Throw error Error: spawn ETXTBSY sometime. As unzip completion not release binary file.
setTimeout(function() {
fs.rename(unzipBinaryPath, destBinaryPath, function(err) {
// if (err) console.error('Got Error while rename binary zip', err);
fs.chmod(destBinaryPath, '0755', function() {
return fnCallback(destBinaryPath);
});
});
}, 1000);
try {
var zip = new AdmZip(binaryPath);
zip.extractAllTo(destParentDir, true);
fs.chmod(destBinaryPath, '0755', function() {
return fnCallback(destBinaryPath)
});
} catch (e) {
console.log("Error log ------> ", e);
logger.log(
conf['user'],
conf['key'],
{ filename: __filename },
conf,
'Got Error while unzip downloading binary' + e
);
self.retryBinaryDownload_(conf, destParentDir, retries, binaryPath, fnCallback);
}
} else {
console.error('Got Error while downloading binary zip');
logger.log(
Expand Down
Loading

0 comments on commit 513e5f5

Please sign in to comment.