fix(discord): chunk long editMessage payloads and guard progress null race
- editMessage now splits >2000-char text: edits the tracked message with the first chunk and appends the rest as follow-up messages, instead of throwing Discord "Invalid Form Body … Must be 2000 or fewer" when promoting a long owner result over a progress message. - syncTrackedProgressMessage captures latestProgressText in a local before the editMessage await, fixing a race where a concurrent resetProgressState() nulled it and crashed with "null is not an object (this.latestProgressText.length)". - Add editMessage regression tests (in-place edit vs. chunked overflow). Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -596,15 +596,19 @@ export class MessageTurnController {
|
||||
return;
|
||||
}
|
||||
|
||||
// Capture the value before the await: a concurrent resetProgressState()
|
||||
// can null `latestProgressText` while editMessage is in flight, which used
|
||||
// to throw "null is not an object (evaluating 'this.latestProgressText.length')".
|
||||
const progressText = this.latestProgressText;
|
||||
if (
|
||||
!this.progressMessageId ||
|
||||
!this.options.channel.editMessage ||
|
||||
!this.latestProgressText
|
||||
!progressText
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rendered = this.renderProgressMessage(this.latestProgressText);
|
||||
const rendered = this.renderProgressMessage(progressText);
|
||||
|
||||
try {
|
||||
await this.options.channel.editMessage(
|
||||
@@ -616,7 +620,7 @@ export class MessageTurnController {
|
||||
this.progressEditFailCount = 0;
|
||||
this.logOutboundAudit('progress-edit', {
|
||||
messageId: this.progressMessageId,
|
||||
textLength: this.latestProgressText.length,
|
||||
textLength: progressText.length,
|
||||
renderedLength: rendered.length,
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user