Unable to get mirrorOptions to work
simongregory opened this issue · 2 comments
This surfaced for me via when trying to build multiple targets (ie ia32/x64) via electron-packager
on Windows (elsewhere I expect an already pre-filled cache avoided the problem). It's the same when isolated to @electron/get
and I think mirrorOptions are getting ignored (or I've misconfigured somehow).
Version wise I'm using :
> npm list @electron/get
bbciplayerdownloads@2.9.2 /Users/simon/code/ipd
└─┬ electron-packager@14.0.4
└── @electron/get@1.4.0
To reproduce you can use:
process.env.DEBUG='*';
const { download } = require('@electron/get');
async function dl() {
const zipFilePath = await download('6.0.5-wvvmp', {
mirrorOptions: {
baseUrl: 'https://github.com/castlabs/electron-releases/releases/download/v'
},
cacheRoot: './.electron-dl-cache'
});
console.log('Download to:', zipFilePath);
}
dl();
or
process.env.DEBUG='*';
const { downloadArtifact } = require('@electron/get');
async function art() {
const zipFilePath = await downloadArtifact({
version: '6.0.5-wvvmp',
artifactName: 'electron',
mirrorOptions: {
baseUrl: 'https://github.com/castlabs/electron-releases/releases/download/v'
},
cacheRoot: './.electron-dl-cache'
});
console.log('Download artifact to:', zipFilePath);
}
art()
and you should see a Mac failure along the lines of
> node download-electron-test.js
@electron/get:index Checking the cache for electron-v6.0.5-wvvmp-darwin-x64.zip +0ms
@electron/get:index Cache miss +2ms
@electron/get:index Downloading https://github.com/electron/electron/releases/download/v6.0.5-wvvmp/electron-v6.0.5-wvvmp-darwin-x64.zip to /var/folders/w1/5zxtsx7j0t5406kqx9hc7h7w0000gn/T/electron-download-0FvTbq/electron-v6.0.5-wvvmp-darwin-x64.zip with options: undefined +44ms
(node:87942) UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found)
at EventEmitter.<anonymous> (/Users/simon/code/ipd/node_modules/got/source/as-stream.js:35:24)
at EventEmitter.emit (events.js:200:13)
at module.exports (/Users/simon/code/ipd/node_modules/got/source/get-response.js:22:10)
at ClientRequest.handleResponse (/Users/simon/code/ipd/node_modules/got/source/request-as-event-emitter.js:155:5)
at Object.onceWrapper (events.js:288:20)
at ClientRequest.emit (events.js:205:15)
at ClientRequest.origin.emit (/Users/simon/code/ipd/node_modules/@szmarczak/http-timer/source/index.js:37:11)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:23)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:17)
at TLSSocket.socketOnData (_http_client.js:452:22)
or get led in the wrong direction by Windows suggesting it's a local file system problem:
PS C:\Users\simongregory\code\ipd> node .\download-test.js
@electron/get:index Checking the cache for electron-v6.0.5-wvvmp-win32-x64.zip +0ms
@electron/get:index Cache miss +6ms
@electron/get:index Downloading https://github.com/electron/electron/releases/download/v6.0.5-wvvmp/electron-v6.0.5-wvvmp-win32-x64.zip to C:\Users\SIMONG~1\AppData\Local\Temp\electron-download-1raX2i\electron-v6.0.5-wvvmp-win32-x64.zip with options: undefined +57ms
(node:1980) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, lstat 'C:\Users\SIMONG~1\AppData\Local\Temp\electron-download-1raX2i\electron-v6.0.5-wvvmp-win32-x64.zip'
(node:1980) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1980) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
But both show that the remote endpoint isn't getting changed to honour the mirror settings.
So, this is because I should be using mirror
and not baseUrl
, which I've found via types.ts.
My confusion started in the README where I wrongly thought that I should be using got
options, and baseUrl
seemed right.