When I replaced pnpm run with nr in my project, the nr command suddenly stopped working.
I investigated the issue and found that the _storage.json, which stores the last run command, was not in the correct JSON format.
The nr command first parses the contents of this JSON file, and I suspect that a syntax error is causing it to exit abnormally.
Cause of Issue
I'm not entirely certain, but I suspect this issue is caused by simultaneous writes to _storage.json when the nr command is run concurrently (my project uses lint-staged, which is where the concurrency is happening).
I found a similar issue in the node repository, which may have the same cause: nodejs/node#26338
Proposed Solutions
I have two potential solutions:
Catch SyntaxError during JSON.parse(<_storage.json>)
The last run command cannot be used when the issue occurs. However, this solution is easy to implement.
If _storage.json is corrupted for any other reason, it will work.
Implement locking when writing to _storage.json
If changes are required for this issue, I would like to work on a pull request. However, I have no experience working on pull requests, so it may take some effort on my part...
Related Issues
This issue may not be related to concurrent running, but this is related to the corruption of _storage.json: #141
Describe the bug
When I replaced
pnpm run
withnr
in my project, thenr
command suddenly stopped working.I investigated the issue and found that the
_storage.json
, which stores the last run command, was not in the correct JSON format.The
nr
command first parses the contents of this JSON file, and I suspect that a syntax error is causing it to exit abnormally.Cause of Issue
I'm not entirely certain, but I suspect this issue is caused by simultaneous writes to
_storage.json
when thenr
command is run concurrently (my project useslint-staged
, which is where the concurrency is happening).I found a similar issue in the node repository, which may have the same cause: nodejs/node#26338
Proposed Solutions
I have two potential solutions:
SyntaxError
duringJSON.parse(<_storage.json>)
_storage.json
is corrupted for any other reason, it will work._storage.json
If changes are required for this issue, I would like to work on a pull request. However, I have no experience working on pull requests, so it may take some effort on my part...
Related Issues
This issue may not be related to concurrent running, but this is related to the corruption of
_storage.json
: #141Reproduction
https://github.com/ot07/nr-command-concurrent-running-storage-file-issue
System Info
Used Package Manager
npm
Validations