-
-
Notifications
You must be signed in to change notification settings - Fork 40
Snapshots not working behind corporate proxy #389
Comments
Our CI build breaks because of this. Any workaround?
|
Confirming this one as not implemented feature. Ping @Pip3r4o @rosen-vladimirov @rosen-vladimirov suggested implementing the usage of request instead of |
@ticklemepierce @mxth @ajswago I can confirm that the snapshot generation does not work while behind a proxy. The problem stems from the fact that node.js does not respect env variables and system proxies by default. The requests made at
will not be influenced by We are currently reviewing the best way to enable http requests behind a proxy in the snapshot scripts, and will let you know when an update with a fix is released. As an immediate work-around the https requests can be replaced by those of the request npm package. const request = require("request");
const downloadFile = (url, destinationFilePath) =>
new Promise((resolve, reject) => {
request
.get(url)
.on('response', response =>
switch (response.statusCode) {
case 200:
const file = createWriteStream(destinationFilePath, { autoClose: true });
file.on('error', function (error) {
return reject(error);
});
file.on("finish", function () {
chmodSync(destinationFilePath, 0755);
return resolve(destinationFilePath);
});
response.pipe(file);
break;
case 301:
case 302:
case 303:
const redirectUrl = response.headers.location;
return this.downloadFile(redirectUrl, destinationFilePath);
default:
return reject(new Error("Unable to download file at " + url + ". Status code: " + response.statusCode));
}
)
.on('error', err => {
return reject(err);
});
});
const getJsonFile = url =>
new Promise((resolve, reject) => {
request
.get(url)
.on('response', res => {
let body = "";
res.on("data", chunk => {
body += chunk;
})
res.on("end", () => {
const data = JSON.parse(body);
return resolve(data);
});
})
.on("error", err => {
return reject(err);
});
}); |
Use 'request' node package, which respects environment proxy variables (i.e. HTTPS_PROXY). fixes #389
Use 'request' node package for https requests and 'proxy-lib' for getting configured proxy settings (see: NativeScript/nativescript-cli:docs/man_pages/general/proxy-set.md@master). fixes #389
It seems that node's https module does not honor environment proxy variables (i.e. HTTPS_PROXY) so the snapshots time out with the requests in utils (getJsonFile and downloadFile).
I'm on node 8.7.0 and nativescript 3.4.0. I'm also using 0.9.0 for this package.
The text was updated successfully, but these errors were encountered: