From a63192852bf2f2d1b8a3b14fa4ea8f083742b0fa Mon Sep 17 00:00:00 2001 From: symwell <111290954+symwell@users.noreply.github.com> Date: Mon, 12 Dec 2022 11:52:03 -0500 Subject: [PATCH] fix: Don't crash on an 'UNKNOWN: unknown error, lstat' error --- .../cli/src/fingerprint/fingerprintWatchCommand.ts | 2 ++ .../unit/fingerprint/fingerprintWatchCommand.spec.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/cli/src/fingerprint/fingerprintWatchCommand.ts b/packages/cli/src/fingerprint/fingerprintWatchCommand.ts index 6d7851efa3..d4bf07503d 100644 --- a/packages/cli/src/fingerprint/fingerprintWatchCommand.ts +++ b/packages/cli/src/fingerprint/fingerprintWatchCommand.ts @@ -52,6 +52,8 @@ export default class FingerprintWatchCommand { await this.watcher?.close(); this.watcher = undefined; console.warn("File watching disabled."); + } else if (error.message.includes("UNKNOWN: unknown error, lstat")) { + console.warn(error.stack); } else { // let it crash if it's some other error, to learn what the error is throw error; diff --git a/packages/cli/tests/unit/fingerprint/fingerprintWatchCommand.spec.ts b/packages/cli/tests/unit/fingerprint/fingerprintWatchCommand.spec.ts index 37e51187f3..29d1bbbf8a 100644 --- a/packages/cli/tests/unit/fingerprint/fingerprintWatchCommand.spec.ts +++ b/packages/cli/tests/unit/fingerprint/fingerprintWatchCommand.spec.ts @@ -93,6 +93,18 @@ describe(FingerprintWatchCommand, () => { expect(cmd.watcher).toBeUndefined(); }); + it('does not raise on unknown error lstat', async () => { + cmd = new FingerprintWatchCommand(appMapDir); + cmd.watcher = new FSWatcher(); + expect(cmd.watcher).not.toBeUndefined(); + console.warn = jest.fn(); + const errorMessage = "UNKNOWN: unknown error, lstat"; + await cmd.watcherErrorFunction(new Error(errorMessage)); + expect(cmd.watcher).not.toBeUndefined(); + expect(console.warn).toBeCalledTimes(1); + expect(console.warn).toHaveBeenCalledWith(expect.stringContaining(errorMessage)); + }); + describe('telemetry', () => { let handler: Fingerprinter;