fix(wechat-browser): fix upload progress check crashing on second iteration
Runtime.evaluate reuses the same JS execution context across calls in a session. The previous expression used `const thumbs = ...` which throws "Identifier 'thumbs' has already been declared" on the second loop iteration, causing result.value to be undefined and JSON.parse to throw "JSON Parse error: Unexpected identifier 'undefined'". Fix by inlining the querySelector into a single expression with no variable declaration, eliminating the re-declaration error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d59ecf22c1
commit
1bdf44df9e
|
|
@ -570,10 +570,7 @@ export async function postToWeChat(options: WeChatBrowserOptions): Promise<void>
|
|||
for (let i = 0; i < 30; i++) {
|
||||
await sleep(2000);
|
||||
const uploadCheck = await cdp.send<{ result: { value: string } }>('Runtime.evaluate', {
|
||||
expression: `
|
||||
const thumbs = document.querySelectorAll('.weui-desktop-upload__thumb, .pic_item, [class*=upload_thumb]');
|
||||
JSON.stringify({ uploaded: thumbs.length });
|
||||
`,
|
||||
expression: `JSON.stringify({ uploaded: document.querySelectorAll('.weui-desktop-upload__thumb, .pic_item, [class*=upload_thumb]').length })`,
|
||||
returnByValue: true,
|
||||
}, { sessionId });
|
||||
const status = JSON.parse(uploadCheck.result.value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue