Skip to content

Commit

Permalink
Warn on failed cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
claabs committed Dec 8, 2024
1 parent 74c3cd9 commit d97dd6f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
46 changes: 26 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions src/common/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ export const killBrowserProcesses = async (L: Logger) => {
})
.filter((name): name is string => typeof name === 'string');
L.debug({ processNames }, 'Killing dangling browser processes');
browserProcesses.forEach((p) => process.kill(p.pid));
browserProcesses.forEach((p) => {
try {
process.kill(p.pid);
} catch (err) {
L.warn({ pid: p.pid, name: p.name, err }, 'Unable to kill process');
}
});
};

export const cleanupTempFiles = async (L: Logger) => {
Expand All @@ -145,7 +151,15 @@ export const cleanupTempFiles = async (L: Logger) => {
const chromiumTempfiles = tempFiles.filter((file) => chromiumMatcher.test(file));
const deletedFiles = [...devProfiles, ...chromiumTempfiles];
L.debug({ deletedFiles }, 'Deleting temp puppeteer dev profile and chromium folders');
await Promise.all(deletedFiles.map((file) => fsx.remove(path.join(tempDir, file))));
await Promise.all(
deletedFiles.map(async (file) => {
try {
await fsx.remove(path.join(tempDir, file));
} catch (err) {
L.warn({ file, err }, 'Unable to delete folder');
}
}),
);
};

/**
Expand Down

0 comments on commit d97dd6f

Please sign in to comment.