Skip to content

fix(stcourier): use the newest scan as the headline status - #26

Merged
Aswinmcw merged 1 commit into
mainfrom
fix/stcourier-status-and-poller-warning
Sep 4, 2026
Merged

fix(stcourier): use the newest scan as the headline status#26
Aswinmcw merged 1 commit into
mainfrom
fix/stcourier-status-and-poller-warning

Conversation

@Aswinmcw

@Aswinmcw Aswinmcw commented Sep 4, 2026

Copy link
Copy Markdown
Member

Two fixes from the first live multi-scan ST Courier shipment (AWB 64424565531).

1. Headline status lagged the scan list

ST Courier's "Current Status" summary cell is not kept in sync with their own timeline:

summary cell      : In Transit
latest scan       : Out for Delivery   (Sep 04, 2026 10:31 AM)

#25 preferred that cell, so /api/track/stcourier/... and the public tracking page reported in_transit while rendering an Out for Delivery scan directly beneath it.

Now prefers the newest scan — matching the Blue Dart carrier — with the summary cell kept only as a fallback for shipments that have no scans yet.

before → headline status: in_transit       (latest scan: out_for_delivery)
after  → headline status: out_for_delivery (latest scan: out_for_delivery)

This did not affect alerting or delivered-detection: the poller already keys lastKnownStatus and the TERMINAL check off latest.status, not result.status.

2. Poller skipped unknown carriers silently

The poller is deployed separately from the web app (npm run deploy:poller, no CI workflow), so a carrier added to the registry goes live on the site while shiptrack-poller still runs the previous bundle. In that window:

const carrier = getCarrier(w.carrier);
if (!carrier) { await markPolled(env.DB, w.id); return; }

markPolled stamps last_polled_at but leaves last_known_status null — so the dashboard shows "awaiting first scan" forever with a fresh last-poll timestamp, no alerts fire, and nothing appears in the logs. That's exactly what happened to the first ST Courier watch after #25 merged.

This adds a console.warn naming the watch and carrier. It doesn't change behaviour — skipping is still correct — it just makes the stale-deploy window diagnosable.

Also confirmed

The open question from #25 — ST Courier's scan render order — is now settled against a 3-scan shipment. parseScans returns correct oldest-first ordering:

[0] Sep 03, 2026 10:49 PM | in_transit       | Processed & Forwarded to Hub
[1] Sep 04, 2026 10:29 AM | in_transit       | Processed & Forwarded to Service Center
[2] Sep 04, 2026 10:31 AM | out_for_delivery | Out for Delivery

tsc --noEmit clean.

Note: merging this does not fix the stuck watch on its own — shiptrack-poller still needs npm run deploy:poller to pick up the ST Courier carrier.

🤖 Generated with Claude Code

ST Courier's "Current Status" summary cell lags its own timeline: for AWB
64424565531 it still read "In Transit" while the latest scan was already
"Out for Delivery". Preferring that cell made /api/track and the public
tracking page report a status behind the scan list rendered right below
it. Prefer the newest scan (matching the Blue Dart carrier) and keep the
summary cell only as a fallback for shipments with no scans yet.

Also log unknown carriers in the poller instead of skipping in silence.
The poller is deployed separately from the web app, so a newly registered
carrier is live on the site while this worker still runs the old bundle.
That path stamped last_polled_at and left last_known_status null, so the
dashboard read "awaiting first scan" indefinitely and no alerts fired,
with nothing in the logs to explain why.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Aswinmcw
Aswinmcw requested review from a team and Aswin-coder as code owners September 4, 2026 10:27
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shiptrack 0fa66a0 Commit Preview URL

Branch Preview URL
Sep 04 2026, 10:29 AM

@Aswincloud-Bot Aswincloud-Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: @Aswinmcw is a member of @Aswincloud/admins.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
shiptrack-poller 0fa66a0 Sep 04 2026, 10:29 AM

@Aswinmcw
Aswinmcw added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 65b397a Sep 4, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants