mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Correctly handle job failures in inboxes
This commit is contained in:
parent
c59ebef851
commit
d527947182
|
|
@ -116,12 +116,18 @@ export default apiRoute((app) =>
|
|||
ip: context.env.ip ?? null,
|
||||
});
|
||||
|
||||
return new Promise<Response>((resolve) => {
|
||||
return new Promise<Response>((resolve, reject) => {
|
||||
inboxWorker.on("completed", (job) => {
|
||||
if (job.id === result.id) {
|
||||
resolve(job.returnvalue);
|
||||
}
|
||||
});
|
||||
|
||||
inboxWorker.on("failed", (job) => {
|
||||
if (job && job.id === result.id) {
|
||||
reject(job.returnvalue);
|
||||
}
|
||||
});
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
24
worker.ts
24
worker.ts
|
|
@ -99,11 +99,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
|||
|
||||
const logger = getLogger(["federation", "inbox"]);
|
||||
|
||||
logger.debug(
|
||||
`Processing entity ${chalk.gray(
|
||||
logger.debug`Processing entity ${chalk.gray(
|
||||
data.id,
|
||||
)} from ${chalk.gray(signedBy)}`,
|
||||
);
|
||||
)} from ${chalk.gray(signedBy)}`;
|
||||
|
||||
if (authorization) {
|
||||
const processor = new InboxProcessor(
|
||||
|
|
@ -119,11 +117,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
|||
ip,
|
||||
);
|
||||
|
||||
logger.debug(
|
||||
`Entity ${chalk.gray(
|
||||
logger.debug`Entity ${chalk.gray(
|
||||
data.id,
|
||||
)} is potentially from a bridge`,
|
||||
);
|
||||
)} is potentially from a bridge`;
|
||||
|
||||
return await processor.process();
|
||||
}
|
||||
|
|
@ -175,13 +171,11 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
|||
);
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`Entity ${chalk.gray(
|
||||
logger.debug`Entity ${chalk.gray(
|
||||
data.id,
|
||||
)} is from remote instance ${chalk.gray(
|
||||
remoteInstance.data.baseUrl,
|
||||
)}`,
|
||||
);
|
||||
)}`;
|
||||
|
||||
const processor = new InboxProcessor(
|
||||
request,
|
||||
|
|
@ -198,11 +192,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
|||
|
||||
const output = await processor.process();
|
||||
|
||||
logger.debug(
|
||||
`${chalk.green(
|
||||
logger.debug`${chalk.green(
|
||||
"✔",
|
||||
)} Finished processing entity ${chalk.gray(data.id)}`,
|
||||
);
|
||||
)} Finished processing entity ${chalk.gray(data.id)}`;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue