summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-02-03 15:03:42 -0500
committerHazelnoot <acomputerdog@gmail.com>2025-02-03 15:03:42 -0500
commit3391c2414b0fc89d897fc3ecf66ca1dffaf6dfe9 (patch)
treeb8da205ca3c959a77a0b9faffce982f20cd54bf8 /packages/backend/src
parentcopy changes to ci.yml and cypress-devcontainer.yml (diff)
downloadsharkey-3391c2414b0fc89d897fc3ecf66ca1dffaf6dfe9.tar.gz
sharkey-3391c2414b0fc89d897fc3ecf66ca1dffaf6dfe9.tar.bz2
sharkey-3391c2414b0fc89d897fc3ecf66ca1dffaf6dfe9.zip
add IdentifiableError.isRetryable to ensure that Identifiable Errors can still terminate a batch process
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/DriveService.ts2
-rw-r--r--packages/backend/src/misc/identifiable-error.ts8
-rw-r--r--packages/backend/src/queue/processors/InboxProcessorService.ts8
3 files changed, 16 insertions, 2 deletions
diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts
index 734ce6b88f..a65059b417 100644
--- a/packages/backend/src/core/DriveService.ts
+++ b/packages/backend/src/core/DriveService.ts
@@ -520,7 +520,7 @@ export class DriveService {
// If usage limit exceeded
if (driveCapacity < usage + info.size) {
if (isLocalUser) {
- throw new IdentifiableError('c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6', 'No free space.');
+ throw new IdentifiableError('c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6', 'No free space.', true);
}
await this.expireOldFile(await this.usersRepository.findOneByOrFail({ id: user.id }) as MiRemoteUser, driveCapacity - info.size);
}
diff --git a/packages/backend/src/misc/identifiable-error.ts b/packages/backend/src/misc/identifiable-error.ts
index 13c41f1e3b..f5c3fcd6cb 100644
--- a/packages/backend/src/misc/identifiable-error.ts
+++ b/packages/backend/src/misc/identifiable-error.ts
@@ -10,9 +10,15 @@ export class IdentifiableError extends Error {
public message: string;
public id: string;
- constructor(id: string, message?: string) {
+ /**
+ * Indicates that this is a temporary error that may be cleared by retrying
+ */
+ public readonly isRetryable: boolean;
+
+ constructor(id: string, message?: string, isRetryable = false) {
super(message);
this.message = message ?? '';
this.id = id;
+ this.isRetryable = isRetryable;
}
}
diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts
index 7727a3e985..87d4bf52fa 100644
--- a/packages/backend/src/queue/processors/InboxProcessorService.ts
+++ b/packages/backend/src/queue/processors/InboxProcessorService.ts
@@ -248,6 +248,14 @@ export class InboxProcessorService implements OnApplicationShutdown {
return `skip: permanent error ${e.statusCode}`;
}
+ if (e instanceof IdentifiableError && !e.isRetryable) {
+ if (e.message) {
+ return `skip: permanent error ${e.id}: ${e.message}`;
+ } else {
+ return `skip: permanent error ${e.id}`;
+ }
+ }
+
throw e;
}
return 'ok';