chore: Add sleep before Slack notification

This commit is contained in:
Tom Moor
2024-03-08 22:02:20 -05:00
parent 8f996ca2f3
commit 1a454d6dbb
3 changed files with 6 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import {
Event,
} from "@server/types";
import fetch from "@server/utils/fetch";
import { sleep } from "@server/utils/timers";
import env from "../env";
import presentMessageAttachment from "../presenters/messageAttachment";
@ -25,6 +26,8 @@ export default class SlackProcessor extends BaseProcessor {
switch (event.name) {
case "documents.publish":
case "revisions.create":
// wait a few seconds to give the document summary chance to be generated
await sleep(5000);
return this.documentUpdated(event);
case "integrations.create":

View File

@ -1,6 +1,6 @@
import groupBy from "lodash/groupBy";
import Logger from "@server/logging/Logger";
import { timeout } from "./timers";
import { sleep } from "./timers";
export enum ShutdownOrder {
first = 0,
@ -59,7 +59,7 @@ export default class ShutdownHelper {
this.isShuttingDown = true;
// Start the shutdown timer
void timeout(this.forceQuitTimeout).then(() => {
void sleep(this.forceQuitTimeout).then(() => {
Logger.info("lifecycle", "Force quitting");
process.exit(1);
});

View File

@ -3,6 +3,6 @@
*
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
*/
export function timeout(ms = 1) {
export function sleep(ms = 1) {
return new Promise((resolve) => setTimeout(resolve, ms));
}