channel-worker 2.5.21 → 2.5.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.5.21",
3
+ "version": "2.5.22",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {
@@ -283,7 +283,7 @@ async function run({ page, payload, log }) {
283
283
  } = payload || {};
284
284
  if (!video_url) throw new Error('No video_url provided');
285
285
 
286
- log('info', '[fb-pw] selectors version=2026.06.19b-thumb-diag');
286
+ log('info', '[fb-pw] selectors version=2026.06.19c-posturl-network-first');
287
287
 
288
288
  page.on('dialog', (d) => { d.accept().catch(() => {}); });
289
289
 
@@ -1914,12 +1914,30 @@ async function run({ page, payload, log }) {
1914
1914
  }
1915
1915
  }
1916
1916
 
1917
- // (a.2) Reel-preview tile on profile reels tab FB sometimes navigates
1918
- // to /profile.php?sk=reels_tab after publish. The FIRST tile in
1919
- // DOM order (with aria-label="Bản xem trước ô thước phim" /
1920
- // "Reel tile preview") is the NEWEST reel = our just-published.
1921
- // Each tile is an <a href="/reel/<id>/"> anchor scraping that
1922
- // href is far more reliable than network-id ordering.
1917
+ // (a.2) Graph API network captureAUTHORITATIVE. The publish-mutation
1918
+ // response carries the JUST-published reel ID. Only consider IDs
1919
+ // captured AFTER the publish-click snapshot (pre-snapshot IDs are the
1920
+ // page-wall feed pre-render, NOT the publish mutation). Take the FIRST
1921
+ // new ID (the mutation response comes back before feed-reload
1922
+ // responses). Prefer this over scraping the reels tab: the new reel
1923
+ // often isn't on the tab yet (still processing), so the tab's "first
1924
+ // tile" is a STALE older reel — which is the bug this ordering fixes.
1925
+ if (!postUrl && capturedReelIds.length > capturedReelIdsSnapshotLen) {
1926
+ const newIds = capturedReelIds.slice(capturedReelIdsSnapshotLen);
1927
+ const preSet = new Set(capturedReelIds.slice(0, capturedReelIdsSnapshotLen));
1928
+ const trulyNew = newIds.filter((id) => !preSet.has(id));
1929
+ if (trulyNew.length) {
1930
+ const firstNew = trulyNew[0];
1931
+ postUrl = `https://www.facebook.com/reel/${firstNew}/`;
1932
+ log('info', `[fb-pw] post URL from network (FIRST new ID after snapshot): ${postUrl} (snapshotLen=${capturedReelIdsSnapshotLen} total=${capturedReelIds.length} new=${trulyNew.length})`);
1933
+ }
1934
+ }
1935
+
1936
+ // (a.3) LAST-RESORT: first reel tile on the profile reels tab. UNRELIABLE —
1937
+ // the just-published reel may not be on the tab yet (still
1938
+ // processing), so the first tile can be a STALE older reel. Only used
1939
+ // when every authoritative source above (fresh-timestamp tile,
1940
+ // title-match, inline CTA, network capture) returned nothing.
1923
1941
  if (!postUrl) {
1924
1942
  const tileHref = await page.evaluate(() => {
1925
1943
  const anchors = document.querySelectorAll("a[role='link']");
@@ -1934,25 +1952,7 @@ async function run({ page, payload, log }) {
1934
1952
  }).catch(() => null);
1935
1953
  if (tileHref) {
1936
1954
  postUrl = tileHref.href.startsWith('http') ? tileHref.href : `https://www.facebook.com${tileHref.href}`;
1937
- log('info', `[fb-pw] post URL from FIRST reel tile on reels_tab: ${postUrl}`);
1938
- }
1939
- }
1940
-
1941
- // (b) Graph API network capture — only consider IDs captured AFTER the
1942
- // publish click snapshot (pre-snapshot IDs are from the page-wall
1943
- // feed pre-render, NOT the publish mutation). Take the FIRST new ID
1944
- // since FB's publish-mutation response comes back before any
1945
- // feed-reload responses.
1946
- if (!postUrl && capturedReelIds.length > capturedReelIdsSnapshotLen) {
1947
- const newIds = capturedReelIds.slice(capturedReelIdsSnapshotLen);
1948
- // Filter out IDs that appeared in the pre-snapshot to be safe (Set
1949
- // diff). Then take the FIRST new one.
1950
- const preSet = new Set(capturedReelIds.slice(0, capturedReelIdsSnapshotLen));
1951
- const trulyNew = newIds.filter((id) => !preSet.has(id));
1952
- if (trulyNew.length) {
1953
- const firstNew = trulyNew[0];
1954
- postUrl = `https://www.facebook.com/reel/${firstNew}/`;
1955
- log('info', `[fb-pw] post URL from network (FIRST new ID after snapshot): ${postUrl} (snapshotLen=${capturedReelIdsSnapshotLen} total=${capturedReelIds.length} new=${trulyNew.length})`);
1955
+ log('warn', `[fb-pw] post URL from FIRST reel tile on reels_tab (LAST-RESORT, may be STALE): ${postUrl}`);
1956
1956
  }
1957
1957
  }
1958
1958