From ee435761fd7e754af591acb5f68738ddea889256 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 28 Apr 2020 15:30:45 +0100 Subject: [PATCH] refactor(ngcc): improve locker pausing message (#36838) When ngcc is having to pause and wait for another process it provides a message to the user. This commit adds the extra information about how to remove the lockfile if desired, since this message is not shown if you Ctrl-C out of the process before the timeout period ends. PR Close #36838 --- .../ngcc/src/locking/async_locker.ts | 4 +++- .../ngcc/test/locking/async_locker_spec.ts | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/locking/async_locker.ts b/packages/compiler-cli/ngcc/src/locking/async_locker.ts index f0ee1b7393..36a8c8faf5 100644 --- a/packages/compiler-cli/ngcc/src/locking/async_locker.ts +++ b/packages/compiler-cli/ngcc/src/locking/async_locker.ts @@ -52,7 +52,9 @@ export class AsyncLocker { if (attempts === 0) { this.logger.info( `Another process, with id ${pid}, is currently running ngcc.\n` + - `Waiting up to ${this.retryDelay * this.retryAttempts / 1000}s for it to finish.`); + `Waiting up to ${this.retryDelay * this.retryAttempts / 1000}s for it to finish.\n` + + `(If you are sure no ngcc process is running then you should delete the lock-file at ${ + this.lockFile.path}.)`); } // The file is still locked by another process so wait for a bit and retry await new Promise(resolve => setTimeout(resolve, this.retryDelay)); diff --git a/packages/compiler-cli/ngcc/test/locking/async_locker_spec.ts b/packages/compiler-cli/ngcc/test/locking/async_locker_spec.ts index a77b34c5d8..9f359b37d8 100644 --- a/packages/compiler-cli/ngcc/test/locking/async_locker_spec.ts +++ b/packages/compiler-cli/ngcc/test/locking/async_locker_spec.ts @@ -76,7 +76,9 @@ runInEachFileSystem(() => { // The lock is now waiting on the lock-file becoming free, so no `fn()` in the log. expect(log).toEqual(['write()', 'read() => 188']); expect(logger.logs.info).toEqual([[ - 'Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.' + 'Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.\n' + + `(If you are sure no ngcc process is running then you should delete the lock-file at ${ + lockFile.path}.)` ]]); lockFileContents = null; @@ -112,7 +114,9 @@ runInEachFileSystem(() => { // The lock is now waiting on the lock-file becoming free, so no `fn()` in the log. expect(log).toEqual(['write()', 'read() => 188']); expect(logger.logs.info).toEqual([[ - 'Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.' + 'Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.\n' + + `(If you are sure no ngcc process is running then you should delete the lock-file at ${ + lockFile.path}.)` ]]); lockFileContents = '444'; @@ -120,12 +124,12 @@ runInEachFileSystem(() => { await new Promise(resolve => setTimeout(resolve, 250)); expect(log).toEqual(['write()', 'read() => 188', 'write()', 'read() => 444']); expect(logger.logs.info).toEqual([ - [ - 'Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.' - ], - [ - 'Another process, with id 444, is currently running ngcc.\nWaiting up to 1s for it to finish.' - ] + ['Another process, with id 188, is currently running ngcc.\nWaiting up to 1s for it to finish.\n' + + `(If you are sure no ngcc process is running then you should delete the lock-file at ${ + lockFile.path}.)`], + ['Another process, with id 444, is currently running ngcc.\nWaiting up to 1s for it to finish.\n' + + `(If you are sure no ngcc process is running then you should delete the lock-file at ${ + lockFile.path}.)`] ]); lockFileContents = null;