Skip to content

Commit b224c79

Browse files
committed
truncate slack text
1 parent 85ac0c6 commit b224c79

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apps/webapp/app/v3/services/alerts/deliverAlert.server.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ export class DeliverAlertService extends BaseService {
617617
type: "section",
618618
text: {
619619
type: "mrkdwn",
620-
text: `\`\`\`${error.stackTrace ?? error.message}\`\`\``,
620+
text: this.#truncateSlackText(`\`\`\`${error.stackTrace ?? error.message}\`\`\``),
621621
},
622622
},
623623
{
@@ -729,7 +729,7 @@ export class DeliverAlertService extends BaseService {
729729
type: "section",
730730
text: {
731731
type: "mrkdwn",
732-
text: `\`\`\`${error.stackTrace ?? error.message}\`\`\``,
732+
text: this.#truncateSlackText(`\`\`\`${error.stackTrace ?? error.message}\`\`\``),
733733
},
734734
},
735735
{
@@ -829,7 +829,9 @@ export class DeliverAlertService extends BaseService {
829829
type: "section",
830830
text: {
831831
type: "mrkdwn",
832-
text: `\`\`\`${preparedError.stack ?? preparedError.message}\`\`\``,
832+
text: this.#truncateSlackText(
833+
`\`\`\`${preparedError.stack ?? preparedError.message}\`\`\``
834+
),
833835
},
834836
},
835837
{
@@ -1047,6 +1049,14 @@ export class DeliverAlertService extends BaseService {
10471049
};
10481050
}
10491051

1052+
#truncateSlackText(text: string) {
1053+
if (text.length > 3000) {
1054+
return text.slice(0, 2900) + "\n\ntruncated - check dashboard for complete error message";
1055+
}
1056+
1057+
return text;
1058+
}
1059+
10501060
static async enqueue(
10511061
alertId: string,
10521062
tx: PrismaClientOrTransaction,

0 commit comments

Comments
 (0)