From 418b54abf352bcf191ea1e114739a6055fb3eabc Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Wed, 8 Jan 2025 15:35:43 -0600 Subject: [PATCH] fix: JS API viewports should throw only for basic data issues (#6537) Network issues now fire requestfailed events to signal that the table was in a bad state. Fixes DH-18331 Backport #6535 --- .../api/subscription/TableViewportSubscription.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java index e9f1bd53233..0bbddfe2fc7 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java @@ -250,6 +250,9 @@ public void setInternalViewport(double firstRow, double lastRow, Column[] column Boolean isReverseViewport) { // Until we've created the stream, we just cache the requested viewport if (status == Status.STARTING) { + if (firstRow < 0 || firstRow > lastRow) { + throw new IllegalArgumentException("Invalid viewport row range: " + firstRow + " to " + lastRow); + } this.firstRow = firstRow; this.lastRow = lastRow; this.columns = columns; @@ -273,8 +276,12 @@ public void setInternalViewport(double firstRow, double lastRow, Column[] column isReverseViewport = false; } RangeSet viewport = RangeSet.ofRange((long) firstRow, (long) lastRow); - this.sendBarrageSubscriptionRequest(viewport, Js.uncheckedCast(columns), updateIntervalMs, - isReverseViewport); + try { + this.sendBarrageSubscriptionRequest(viewport, Js.uncheckedCast(columns), updateIntervalMs, + isReverseViewport); + } catch (Exception e) { + fireEvent(JsTable.EVENT_REQUEST_FAILED, e.getMessage()); + } } /**