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
This commit is contained in:
Pete Bacon Darwin 2020-04-28 15:30:45 +01:00 committed by Alex Rickabaugh
parent 35c6ed2675
commit ee435761fd
2 changed files with 15 additions and 9 deletions

View File

@ -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));

View File

@ -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;