microsoft / dtslint

A utility built on TSLint for linting TypeScript declaration (.d.ts) files.
MIT License
925 stars 86 forks source link

Add concurrency explanation -> FAQ #343

Closed jablko closed 3 years ago

jablko commented 3 years ago

I ran into this issue here:

$ lerna run test-types
lerna notice cli v3.22.1
lerna info ci enabled
lerna info Executing command in 8 packages: "yarn run test-types"
lerna ERR! yarn run test-types exited 1 in '@mdx-js/react'
lerna ERR! yarn run test-types stdout:
$ dtslint types
Installing to /home/runner/.dts/typescript-installs/3.8...
Installed!

Installing to /home/runner/.dts/typescript-installs/4.0...
Installed!

Installing to /home/runner/.dts/typescript-installs/4.2...
Installed!

Installing to /home/runner/.dts/typescript-installs/4.3...
Installed!

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run test-types stderr:
Error: Cannot find module '/home/runner/.dts/typescript-installs/4.5/node_modules/typescript'
Require stack:
- /home/runner/work/mdx/mdx/node_modules/dtslint/bin/lint.js
- /home/runner/work/mdx/mdx/node_modules/dtslint/bin/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at testDependencies (/home/runner/work/mdx/mdx/node_modules/dtslint/bin/lint.js:66:16)
    at /home/runner/work/mdx/mdx/node_modules/dtslint/bin/lint.js:26:28
    at Generator.next (<anonymous>)
    at /home/runner/work/mdx/mdx/node_modules/dtslint/bin/lint.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/runner/work/mdx/mdx/node_modules/dtslint/bin/lint.js:4:12)
error Command failed with exit code 1.

The failed invocation installed 3.8, 4.0, etc., a concurrent invocation installed 3.9, 4.5, etc. The failed invocation found the 4.5 directory but didn't wait for the 4.5 installation to complete and failed as a result (I surmise).

Solved with lerna --concurrency 1 run .... I suspect this is also the cause behind https://github.com/mdx-js/mdx/issues/1172 and #267.

Fixes #267

jablko commented 3 years ago

Thanks for the update. What do you think about the suggested change to the previous line?

Sounds good :+1: I've updated that line.

This FAQ is to do with installing one list of TypeScript versions, and testing another, which can only happen if you end up with two different @definitelytyped/typescript-versions (I think). I haven't investigated the current dtslint/dtslint-runner/typescript-versions relationship to confirm how that could happen ...

I do vaguely recollect encountering this in the past ... There are child worker processes involved if I remember, so maybe somewhere in there the process doing the installing uses one node_modules and the one doing the testing uses another ...