-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add mutex to ts-patch install
#75
Comments
ts-patch install
ts-patch install
Great point. Thanks for raising this. The main option with node would be to use file locking, but it turns out this is a little tricky in terms of multi-OS support. What I ended up doing was simply creating a temporary file in the destination directory (the specific ts package path). With this route, we essentially indicate that this ts install path is "locked". I also added logic so that it will retry up to 3 times with 10sec pause. This should alleviate any issues. While we do have a proper That said, I think the bases are pretty well covered in this approach. Feel free to weigh in if you have any thoughts. All that is left to do is add in some proper tests, and I'll get a release together. |
Is there any progress in this matter ? |
- Added Live Compiler (on-the-fly, in-memory patching) - Added experimental ES Module support (closes #58) - Added mutex locks (closes #75) - Updated to support TS v5+ (closes #83 closes #93) - Fixed patching for non-standard libraries (cannot guarantee they will work as expected in IDEs) (closes #85) - Added caching
Added in v3 |
I'm using
ts-patch
in a monorepo withrushjs
andpnpm
. When installing multiple projects (=multiplepackage.json
files) at once, theprepare
script callingts-patch install -s
in each of thepackage.json
files can cause havoc. PNPM does magic with symlinks, so many projects will share the same dependency files.In summary, the PNPM installation goes something like this:
prepare
script on all projects in the monorepo at the same time (=parallel execution)This leads to incidents where the patch to
node_modules/typescript
is applied incorrectly or partially.ts-patch
has a check for already patched files, but if twoprepare
scripts run simultaneously, that check can be missed.In order to fix this reliably, I applied a mutex to all the
prepare
scripts in my monorepo, changing theprepare
from this:To this:
That has fixed the patch issues for me. Ideally the mutex should be part of
ts-patch
though, so everyone using PNPM/Rush.js wouldn't have to write their own mutex scripts.Error example:
The text was updated successfully, but these errors were encountered: