unable to run multiple times
dogmatic69 opened this issue · comments
problem
Works fine the first call but calling consecutive times results in an error. Restarting the node process results in the call working but again just the one time.
Does not matter if the cloned repo is deleted or not, consecutive calls never work.
expected
Should be able to call the function repeatedly and get the same result
error
RangeError: path should be a `path.relative()`d string, but got "../repos-e709b5ad-83c9-439a-ad0c-22d3a1193cc1KMhgcm"
at throwError (/app/node_modules/ignore/index.js:364:9)
at checkPath (/app/node_modules/ignore/index.js:383:12)
at Ignore._test (/app/node_modules/ignore/index.js:504:5)
at Ignore.test (/app/node_modules/ignore/index.js:562:17)
at analyse (/app/node_modules/linguist-js/dist/index.js:89:47)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.self.techStack (/app/src/lib.js:34:19)
at async techStack (/app/src/controller.js:32:19)
2022-03-19T11:23:17.012Z error: uncaughtException: path should be a `path.relative()`d string, but got "../repos-e709b5ad-83c9-439a-ad0c-22d3a1193cc1KMhgcm"
RangeError: path should be a `path.relative()`d string, but got "../repos-e709b5ad-83c9-439a-ad0c-22d3a1193cc1KMhgcm"
at throwError (/app/node_modules/ignore/index.js:364:9)
at checkPath (/app/node_modules/ignore/index.js:383:12)
at Ignore._test (/app/node_modules/ignore/index.js:504:5)
at Ignore.test (/app/node_modules/ignore/index.js:562:17)
at analyse (/app/node_modules/linguist-js/dist/index.js:89:47)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.self.techStack (/app/src/lib.js:34:19)
at async techStack (/app/src/controller.js:32:19)
code
const linguist = require('linguist-js');
const fs = require('fs').promises;
const path = require('path');
const os = require('os');
const { v4: uuid } = require('uuid');
const tmpDir = () => fs.mkdtemp(path.join(os.tmpdir(), `repos-${uuid()}`));
const run = async ({ org, repo, user, token }) => {
const git = SimpleGit();
const dir = await tmpDir();
await git.clone(`https://${user}:${token}@github.com/${org}/${repo}.git`, dir);
const stack = await linguist(dir, {
categories: ['data', 'markup', 'programming', 'prose'],
ignore: [
'yarn.lock',
'package-lock.json',
],
});
};
I've debugged the folder I pass to linguist "getting dir:..." and then at this line debugged what is being processed
Even though the second time passing a different folder, the first folder is some how being processed.
Seems to me the walk is cached or something?
first run
// path requested
Getting dir: /tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ
// contents of /tmp - note there are many other dirs from previous runs
[
'repos-0a67eea0-9eda-4c26-93a9-f32b9766adffLmcAob',
'repos-105be0e8-d125-41e8-bff5-7f4a79140901JijchF',
'repos-21ae90ce-eb50-4ae6-95d8-bf6296a9f5a7iHmHEc',
'repos-ba83e13b-b50a-490f-8e20-3b3080d61bfafAIOhl',
'repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ', // <-- new one
'v8-compile-cache-0',
'yarn--1647698425451-0.859800277564736'
]
// line 50 of index.ts
resolvedInput [ '/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ' ]
// line 51 or index.tx
commonRoot /tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ
// resolved dirs from walk
[
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.devcontainer',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github/ISSUE_TEMPLATE',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github/workflows',
...
.. 234 more items
Second run
// path requested - note it is different to last path
Getting dir: /tmp/repos-f6cf1998-0a1d-4318-ae5e-74faaa73f782cmIIii
// contents of /tmp
[
'repos-0a67eea0-9eda-4c26-93a9-f32b9766adffLmcAob',
'repos-105be0e8-d125-41e8-bff5-7f4a79140901JijchF',
'repos-21ae90ce-eb50-4ae6-95d8-bf6296a9f5a7iHmHEc',
'repos-ba83e13b-b50a-490f-8e20-3b3080d61bfafAIOhl',
'repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ',
'repos-f6cf1998-0a1d-4318-ae5e-74faaa73f782cmIIii', // <-- new one
'v8-compile-cache-0',
'yarn--1647698425451-0.859800277564736'
]
// line 50 of index.ts - note it is what was passed in so correct.
resolvedInput [ '/tmp/repos-f6cf1998-0a1d-4318-ae5e-74faaa73f782cmIIii' ]
// line 51, again correct
commonRoot /tmp/repos-f6cf1998-0a1d-4318-ae5e-74faaa73f782cmIIii
// resolved dirs from walk - Wrong values, contains last run
[
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.devcontainer',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github/ISSUE_TEMPLATE',
'/tmp/repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ/.github/workflows',
// error due to wrong path
2022-03-19T14:05:02.125Z error: uncaughtException: path should be a `path.relative()`d string, but got "../repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ"
RangeError: path should be a `path.relative()`d string, but got "../repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ"
...
2022-03-19T14:05:02.125Z error: uncaughtException: path should be a `path.relative()`d string, but got "../repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ"
RangeError: path should be a `path.relative()`d string, but got "../repos-f44970fe-ab18-4c05-a6c3-8905f8a53812jNbNMJ"
...
Seems it is here.
Thanks a lot for the debugging! I'll make a patch release for that today.
Should be fixed in 2.4.2
Confirmed working 🥇