fix(studio): recover uncertain imports with persistent request identities
CI / check (push) Successful in 3m12s
CI / deploy (push) Successful in 19s
CI / publish-container (push) Successful in 1m12s

This commit is contained in:
Simo committed 2026-09-13 18:33:06 +02:00
1 parent afea80708c
commit c977fe95ba
12 files changed
+365 -31

No files matched your search

+11 -2
View File
@@ -10,6 +10,11 @@ export const validJobId = (value: unknown): value is string =>
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
value,
);
export class ImportRequestConflict extends Error {
constructor() {
super("Request ID already used");
}
}
export class ImportJobStore {
constructor(readonly root = importRoot()) {}
async save(job: ImportJob) {
@@ -31,8 +36,11 @@ export class ImportJobStore {
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
const existing = await this.read(job.id);
if (existing.userId !== job.userId)
throw Error("Request ID already used");
if (
existing.userId !== job.userId ||
existing.requestFingerprint !== job.requestFingerprint
)
throw new ImportRequestConflict();
return existing;
} finally {
await fs.unlink(tmp);
@@ -106,6 +114,7 @@ export class ImportJobStore {
...original,
id: retryId,
retryOf: id,
requestFingerprint: undefined,
createdAt: now,
updatedAt: now,
state: "queued",