fix(wechat): retry missing page thumbnails in fresh sessions
Memind CI / Test, build, and release guards (pull_request) Successful in 4m1s
Memind CI / Test, build, and release guards (pull_request) Successful in 4m1s
This commit is contained in:
+10
-5
@@ -1030,6 +1030,7 @@ export function isRecoverableWechatAgentSessionError(message) {
|
||||
const normalized = String(message ?? '').trim();
|
||||
if (!normalized) return false;
|
||||
if (/stale_session_poisoned_completion/i.test(normalized)) return true;
|
||||
if (/wechat_page_fresh_thumbnail_required:/i.test(normalized)) return true;
|
||||
if (/403|404|not found|无权访问/i.test(normalized)) return true;
|
||||
if (/tool_calls|tool_call_id|insufficient tool messages/i.test(normalized)) return true;
|
||||
if (/session already has an active request|active request.*cancel/i.test(normalized)) return true;
|
||||
@@ -1840,6 +1841,7 @@ export function createWechatMpService({
|
||||
user,
|
||||
imagePolicy,
|
||||
publishDir,
|
||||
notifyFailure = true,
|
||||
}) => {
|
||||
if (imagePolicy?.pageThumbnailMode !== WECHAT_PAGE_THUMBNAIL_MODE.REQUIRED_FRESH) return;
|
||||
const images = collectWechatGeneratedImages(reply?.messages ?? []);
|
||||
@@ -1860,14 +1862,16 @@ export function createWechatMpService({
|
||||
}
|
||||
}
|
||||
const text = buildPagePublishFailureText({ missingFreshThumbnail: true });
|
||||
try {
|
||||
await sendCustomerServiceText(openid, text, user);
|
||||
} catch (sendErr) {
|
||||
logger.error?.('WeChat MP fresh thumbnail failure notice failed:', sendErr);
|
||||
if (notifyFailure) {
|
||||
try {
|
||||
await sendCustomerServiceText(openid, text, user);
|
||||
} catch (sendErr) {
|
||||
logger.error?.('WeChat MP fresh thumbnail failure notice failed:', sendErr);
|
||||
}
|
||||
}
|
||||
const error = new Error(`wechat_page_fresh_thumbnail_required:${verification.reason}`);
|
||||
error.code = 'WECHAT_PAGE_FRESH_THUMBNAIL_REQUIRED';
|
||||
throw markWechatUserNotified(error);
|
||||
throw notifyFailure ? markWechatUserNotified(error) : error;
|
||||
};
|
||||
|
||||
const ensureSessionProvider = async (sessionId) => {
|
||||
@@ -2351,6 +2355,7 @@ export function createWechatMpService({
|
||||
user,
|
||||
imagePolicy,
|
||||
publishDir: workingDir,
|
||||
notifyFailure: false,
|
||||
});
|
||||
}
|
||||
const pageDataOutcome = await enforcePageDataCollectDelivery({
|
||||
|
||||
Reference in New Issue
Block a user