mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38: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,
|
ip: context.env.ip ?? null,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise<Response>((resolve) => {
|
return new Promise<Response>((resolve, reject) => {
|
||||||
inboxWorker.on("completed", (job) => {
|
inboxWorker.on("completed", (job) => {
|
||||||
if (job.id === result.id) {
|
if (job.id === result.id) {
|
||||||
resolve(job.returnvalue);
|
resolve(job.returnvalue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inboxWorker.on("failed", (job) => {
|
||||||
|
if (job && job.id === result.id) {
|
||||||
|
reject(job.returnvalue);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
36
worker.ts
36
worker.ts
|
|
@ -99,11 +99,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
|
|
||||||
const logger = getLogger(["federation", "inbox"]);
|
const logger = getLogger(["federation", "inbox"]);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug`Processing entity ${chalk.gray(
|
||||||
`Processing entity ${chalk.gray(
|
data.id,
|
||||||
data.id,
|
)} from ${chalk.gray(signedBy)}`;
|
||||||
)} from ${chalk.gray(signedBy)}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (authorization) {
|
if (authorization) {
|
||||||
const processor = new InboxProcessor(
|
const processor = new InboxProcessor(
|
||||||
|
|
@ -119,11 +117,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
ip,
|
ip,
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug`Entity ${chalk.gray(
|
||||||
`Entity ${chalk.gray(
|
data.id,
|
||||||
data.id,
|
)} is potentially from a bridge`;
|
||||||
)} is potentially from a bridge`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return await processor.process();
|
return await processor.process();
|
||||||
}
|
}
|
||||||
|
|
@ -175,13 +171,11 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(
|
logger.debug`Entity ${chalk.gray(
|
||||||
`Entity ${chalk.gray(
|
data.id,
|
||||||
data.id,
|
)} is from remote instance ${chalk.gray(
|
||||||
)} is from remote instance ${chalk.gray(
|
remoteInstance.data.baseUrl,
|
||||||
remoteInstance.data.baseUrl,
|
)}`;
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
const processor = new InboxProcessor(
|
const processor = new InboxProcessor(
|
||||||
request,
|
request,
|
||||||
|
|
@ -198,11 +192,9 @@ export const inboxWorker = new Worker<InboxJobData, Response, InboxJobType>(
|
||||||
|
|
||||||
const output = await processor.process();
|
const output = await processor.process();
|
||||||
|
|
||||||
logger.debug(
|
logger.debug`${chalk.green(
|
||||||
`${chalk.green(
|
"✔",
|
||||||
"✔",
|
)} Finished processing entity ${chalk.gray(data.id)}`;
|
||||||
)} Finished processing entity ${chalk.gray(data.id)}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue