Re: [angular/angular] fix(ngcc): implement lockfile (#34722)

From: notifications@github.com
Domain: IP info github.com
MX-server: IP info out-23.smtp.github.com
Size: 2962 Bytes
Create: 2020-01-16
Update: 2020-01-16
Score: 0
Safe: Yes

Outbound domains: github.com |

@JoostK commented on this pull request.


In packages/compiler-cli/ngcc/src/execution/lock_file.ts:

> +    try {
+      // To avoid race conditions, we check for existence of the lockfile
+      // by actually trying to create it exclusively
+      this.fs.writeFile(this.lockFilePath, process.pid.toString(), /* exclusive */ true);
+    } catch (e) {
+      if (e.code !== 'EEXIST') {
+        throw e;
+      }
+
+      // The lockfile already exists so raise a helpful error.
+      // It is feasible that the lockfile was removed between the previous check for existence
+      // and this file-read. If so then we still error but as gracefully as possible.
+      let pid: string;
+      try {
+        pid = this.fs.readFile(this.lockFilePath);
+      } catch (e) {

@petebacondarwin it's been supported since TS2.5! https://mariusschulz.com/blog/optional-catch-binding-in-typescript


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Want to protect your real email from messages like this? Use TempM email and be more secure on the internet.