lukeed / lukeed/watchlist

Watchlist throws: The "path" argument must be of type string. Received null

Open
#22 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
262
Forks
15
PR merge metrics
No merged PRs in 30d

Description

[index.js line 60](https://github.com/lukeed/watchlist/blob/master/src/index.js#L60) is throwing:

> TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null

I added some code to debug, and found that filename = null, and type = "changed", but dir looked good.

```js
// index.js
...
async function onChange(dir, type, filename) {
if (ignores.some(x => x.test(filename))) return;

// begin my code
if (filename === null) {
throw new Error(`
filename=null
dir=${ dir}
type=${ type }
datetime=${ new Date().toString() }
`);
}
// end my code

let tmp = join(dir, filename);
if (Triggers.has(tmp)) return;
...
```

**OS:** Windows 10

**Replication:**
I have been unable to figure out replication steps. The error happens maybe once or twice per day. I believe it's correlated to using Sublime Text 4's "find all", which searches the directory that `watchlist` is watching.

Definitely not every time I do a "find all". For example, I've had `watchlist` running all this morning, and the 8th time I did "find all", `watchlist` died.

Related: https://nodejs.org/api/fs.html#filename-argument

Any thoughts on ignoring `null` file names?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading src/index.js around line 60, especially onChange and how filesystem events supply filename on Windows. Investigate the reported Sublime Text 4 “find all” activity as a possible trigger. Done means a null filename no longer crashes watchlist while normal file changes continue to trigger commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.