Skip to content

Automatically retry download failures #153

@bobbrow

Description

@bobbrow

Recently we've been hitting the following problem with our CI on macOS for the CMake Tools extension:

Found /Users/runner/work/vscode-cmake-tools/vscode-cmake-tools/.vscode-test/vscode-darwin-1.68.1. Skipping download.
events.js:[377](https://github.com/microsoft/vscode-cmake-tools/runs/6974144243?check_suite_focus=true#step:4:378)
      throw er; // Unhandled 'error' event
      ^
Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on ClientRequest instance at:
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}
error Command failed with exit code 1.

It's not consistent, but it is happening enough to be disruptive. I traced it to this line which is not wrapped with try/catch:

options.vscodeExecutablePath = await downloadAndUnzipVSCode(options);

It seems a related issue was opened a few years ago to make this API catchable: #49 But if I try to wrap my runTests call in a try/catch, it still doesn't work. Reading around the Internet, I also came across this issue which seems related: nodejs/node#27916

Uncaught Error Error: read ECONNRESET
    at __node_internal_captureLargerStackTrace (node:internal/errors:465:5)
    at __node_internal_errnoException (node:internal/errors:595:12)
    at onStreamRead (node:internal/stream_base_commons:217:20)
    at callbackTrampoline (node:internal/async_hooks:130:17)
    --- TickObject ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:201:43)
    at emitInitScript (node:internal/async_hooks:506:3)
    at nextTick (node:internal/process/task_queues:133:5)
    at onDestroy (node:internal/streams/destroy:96:15)
    at Socket._destroy (node:net:714:5)
    at _destroy (node:internal/streams/destroy:102:25)
    at destroy (node:internal/streams/destroy:64:5)
    at onStreamRead (node:internal/stream_base_commons:217:12)
    at callbackTrampoline (node:internal/async_hooks:130:17)
    --- TLSWRAP ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:201:43)
    at TLSSocket._wrapHandle (node:_tls_wrap:618:24)
    at TLSSocket (node:_tls_wrap:517:18)
    at connect (node:_tls_wrap:1625:19)
    at createConnection (node:https:143:22)
    at createSocket (node:_http_agent:340:26)
    at addRequest (node:_http_agent:291:10)
    at ClientRequest (node:_http_client:311:16)
    at request (node:https:353:10)
    at get (node:https:387:15)
    at <anonymous> (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/request.js:18:15)
    at getJSON (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/request.js:17:12)
    at fetchLatestStableVersion (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/download.js:21:36)
    at download (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/download.js:156:25)
    at downloadAndUnzipVSCode (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/download.js:218:18)
>    at runTests (/Users/bob/git/vscode-cmake-tools/node_modules/vscode-test/out/runTest.js:17:57)
    at main (/Users/bob/git/vscode-cmake-tools/test/smoke/badProject/runTest.ts:17:27)
    at <anonymous> (/Users/bob/git/vscode-cmake-tools/test/smoke/badProject/runTest.ts:29:6)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:822:12)
    at executeUserEntryPoint (node:internal/modules/run_main:77:12)
    at <anonymous> (node:internal/main/run_main_module:17:47)

To Reproduce

Run the following commands on an M1 mac. (requires yarn v1)

mkdir repro
cd repro
git clone https://github.com/microsoft/vscode-cmake-tools.git
cd vscode-cmake-tools
yarn smokeTests

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions