azure-pipelines-task-lib: Mock Test Runner fails to download a new NodeJS distribution
Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues
Environment
azure-pipelines-task-lib version: 2.9.3
Issue Description
While executing unit tests, when calling MockTestRunner.run()
a binary distribution of NodeJS is being downloaded. While running on a ubuntu-latest
agent, the download fails without any information error.
Expected behaviour
The NodeJS binary is downloaded successfully. The test runs.
Actual behaviour
An error is thrown during the test with the following message:
Downloading file: https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz
Steps to reproduce
- Clone https://github.com/codexarcana/azure-tasks
- Create an azure pipeline with the following code:
npm install npm run test
Logs
FAIL tests/integration.test.ts
● Console
console.log
Downloading file: https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.gz
at MockTestRunner.downloadFile (node_modules/azure-pipelines-task-lib/mock-test.js:228:17)
● should succeed with simple inputs
6 |
7 | const testPath = path.join(__dirname, 'success.integration.js');
> 8 | const testMockRunner = new MockTestRunner(testPath);
| ^
9 |
10 | testMockRunner.run(10);
11 |
at doRequest (node_modules/sync-request/index.js:27:11)
at MockTestRunner.downloadFile (node_modules/azure-pipelines-task-lib/mock-test.js:230:22)
at MockTestRunner.downloadTarGz (node_modules/azure-pipelines-task-lib/mock-test.js:242:14)
at MockTestRunner.downloadNode (node_modules/azure-pipelines-task-lib/mock-test.js:206:22)
at MockTestRunner.getNodePath (node_modules/azure-pipelines-task-lib/mock-test.js:147:25)
at new MockTestRunner (node_modules/azure-pipelines-task-lib/mock-test.js:28:30)
at tests/integration.test.ts:8:28
at step (tests/integration.test.ts:33:23)
at Object.next (tests/integration.test.ts:14:53)
at tests/integration.test.ts:8:71
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 15 (4 by maintainers)
I’m facing the same issue as well (using node v12.4.0 and azure-pipelines-task-lib 2.10.0). It seems like the problem is the buffer size to sync-request.
I had to change line 25 in sync-request/index.js to include max buffer size to make it work.
var res = spawnSync(process.execPath, [require.resolve('./lib/worker.js')], {input: req, maxBuffer: 50 * 1024 * 1024});
I’m using azure-pipelines-task-lib version: 2.9.5 in Azure DevOps - Node 10
The error mentioned above comes up on Ubuntu 18 as well as Windows…
When will this be fixed?
Hi everyone! The root cause of the problem is a known issue with the outdated version of sync-request (https://github.com/ForbesLindesay/sync-request/issues/81). Updating task-lib version to latest solved the issue in @ElderMael’s repository. If updating task-lib is not an option for you, than the easiest fix would be to modify
sync-request
’s index.js inside node_modules by addingmaxBuffer: 1024 ** 4
to spawnSync optionsFeel free to reopen this issue if you have any questions.
Finally solved by following below steps to bypass the node.exe downloading
I was able to fix this issue by using Node v10.18.0 as opposed to a newer version