profiles: use a fixed profile dir instead of creating a new temp dir on each load (#858)

- Avoid accumulation of temp profile dirs if crawler is restarted
multiple times, eg. if tmp dir is mapped to `/crawls` (as is in
Browsertrix now), this prevents a proliferation of
`/crawls/tmp/profile-*` dirs for each crawler restart.
- Since profile is loaded each time, clear out existing profile dir.
- bump to 1.6.4
This commit is contained in:
Ilya Kreymer 2025-07-03 19:03:46 -07:00 committed by GitHub
parent 742f56f008
commit 05eb101867
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "browsertrix-crawler", "name": "browsertrix-crawler",
"version": "1.6.3", "version": "1.6.4",
"main": "browsertrix-crawler", "main": "browsertrix-crawler",
"type": "module", "type": "module",
"repository": "https://github.com/webrecorder/browsertrix-crawler", "repository": "https://github.com/webrecorder/browsertrix-crawler",

View file

@ -76,7 +76,11 @@ export class Browser {
screenWHRatio: number; screenWHRatio: number;
constructor() { constructor() {
this.profileDir = fs.mkdtempSync(path.join(os.tmpdir(), "profile-")); this.profileDir = path.join(os.tmpdir(), "btrixProfile");
if (fs.existsSync(this.profileDir)) {
fs.rmSync(this.profileDir, { recursive: true, force: true });
}
fs.mkdirSync(this.profileDir);
// must be provided, part of Dockerfile // must be provided, part of Dockerfile
assert(process.env.GEOMETRY); assert(process.env.GEOMETRY);