From fd9c8a7efc9dd59d9b22e8869134d15c658f454f Mon Sep 17 00:00:00 2001 From: winrid Date: Fri, 10 Jul 2026 16:27:54 -0700 Subject: [PATCH] Fix EU event-log fallback to query EU host subscribeToChanges correctly routes the WebSocket to wss://ws-eu.fastcomments.com for EU tenants, but the "fetch missed events" REST fallback always built its PublicApi against the default host (https://fastcomments.com). For EU tenants that silently queried US infra and returned nothing, so events missed while disconnected were never replayed. Thread config.region into fetchEventLog and point the ApiClient at https://eu.fastcomments.com when region is "eu". --- .../fastcomments/pubsub/LiveEventSubscriber.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java b/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java index b96d7603..12e4f5cc 100644 --- a/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java +++ b/pubsub/src/main/java/com/fastcomments/pubsub/LiveEventSubscriber.java @@ -202,7 +202,7 @@ public void onOpen(WebSocket webSocket, Response response) { // Fetch missed events if we have a last event time if (lastEventTime > 0) { - fetchEventLog(tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), + fetchEventLog(config.region, tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), events -> processEvents(events, canSeeCommentsCallback, handleLiveEvent)); } @@ -253,7 +253,7 @@ public void onFailure(WebSocket webSocket, Throwable t, Response response) { // Fetch missed events if we have a last event time if (lastEventTime > 0) { - fetchEventLog(tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), + fetchEventLog(config.region, tenantId, urlId, userIdWS, lastEventTime, new Date().getTime(), events -> processEvents(events, canSeeCommentsCallback, handleLiveEvent)); } } @@ -323,6 +323,7 @@ public void run() { * Fetch event log from API using PublicApi client */ private static void fetchEventLog( + String region, String tenantId, String urlId, String userIdWS, @@ -331,8 +332,13 @@ private static void fetchEventLog( Consumer> callback ) { try { - // Create PublicApi instance with its own HTTP client - PublicApi publicApi = new PublicApi(new ApiClient(httpClient)); + // Create PublicApi instance with its own HTTP client, pointed at the region's host + // so the "fetch missed events" fallback queries EU infra for EU tenants instead of US. + ApiClient apiClient = new ApiClient(httpClient); + if (Objects.equals(region, "eu")) { + apiClient.setBasePath("https://eu.fastcomments.com"); + } + PublicApi publicApi = new PublicApi(apiClient); // Create API request PublicApi.APIgetEventLogRequest request =