channel-worker 2.5.38 → 2.5.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/upload_facebook.js +18 -2
package/package.json
CHANGED
|
@@ -1556,14 +1556,30 @@ async function run({ page, payload, log }) {
|
|
|
1556
1556
|
// Re-find + re-click up to 3×, and on the last try fall back to a raw
|
|
1557
1557
|
// JS dispatch (bypasses Playwright's obscured/stable guards).
|
|
1558
1558
|
let clickedPublish = false;
|
|
1559
|
+
let attemptedClick = false;
|
|
1560
|
+
// The publish button is gone → the composer closed, which on FB means
|
|
1561
|
+
// the post was ACCEPTED. Critical guard against the false-failure that
|
|
1562
|
+
// caused double-posts: FB registers the click and closes the composer,
|
|
1563
|
+
// but Playwright's click() promise still throws a timeout as the node
|
|
1564
|
+
// detaches. Treating that as a failure marked the idea unpublished →
|
|
1565
|
+
// the user re-posted → duplicate reel. So: if the button vanished
|
|
1566
|
+
// after we clicked, it went through.
|
|
1567
|
+
const publishBtnGone = async () => !(await findByVerbs(publishVerbs, { requireBottomHalf: true }));
|
|
1559
1568
|
for (let attempt = 0; attempt < 3 && !clickedPublish; attempt++) {
|
|
1560
1569
|
const target = attempt === 0 ? pub : await findByVerbs(publishVerbs, { requireBottomHalf: true });
|
|
1561
|
-
if (!target) {
|
|
1570
|
+
if (!target) {
|
|
1571
|
+
if (attemptedClick) { clickedPublish = true; log('info', '[fb-pw] publish button gone after click → post accepted'); break; }
|
|
1572
|
+
await page.waitForTimeout(1500); continue;
|
|
1573
|
+
}
|
|
1574
|
+
attemptedClick = true;
|
|
1562
1575
|
try {
|
|
1563
1576
|
await target.hit.click({ timeout: 15000 });
|
|
1564
1577
|
clickedPublish = true;
|
|
1565
1578
|
} catch (ce) {
|
|
1566
|
-
log('warn', `[fb-pw] publish click attempt ${attempt + 1}/3
|
|
1579
|
+
log('warn', `[fb-pw] publish click attempt ${attempt + 1}/3 threw: ${ce.message.slice(0, 90)}`);
|
|
1580
|
+
// Click may have registered before the node detached — if the
|
|
1581
|
+
// button is now gone, the post went through.
|
|
1582
|
+
if (await publishBtnGone()) { clickedPublish = true; log('info', '[fb-pw] click threw but publish button gone → post accepted'); break; }
|
|
1567
1583
|
if (attempt === 2) {
|
|
1568
1584
|
const js = await page.evaluate(() => {
|
|
1569
1585
|
const el = document.querySelector("[__fbpw_target__='1']")
|