Skip to content

Commit

Permalink
Also fix a related issue where racing view changes can log an err
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Jan 27, 2025
1 parent e841462 commit ee6c53f
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import elemental2.core.JsArray;
import elemental2.core.JsObject;
import elemental2.core.Uint8Array;
import elemental2.dom.AbortController;
import elemental2.dom.DomGlobal;
import elemental2.promise.IThenable;
import elemental2.promise.Promise;
Expand All @@ -18,6 +19,7 @@
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.hierarchicaltable_pb.HierarchicalTableSourceExportRequest;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.hierarchicaltable_pb.HierarchicalTableViewKeyTableDescriptor;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.hierarchicaltable_pb.HierarchicalTableViewRequest;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.hierarchicaltable_pb_service.UnaryResponse;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.Condition;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.ExportedTableCreationResponse;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.SortDescriptor;
Expand Down Expand Up @@ -354,24 +356,34 @@ private TicketAndPromise<ClientTableState> makeView(TicketAndPromise<?> prevTick
}
Ticket ticket = connection.getConfig().newTicket();
Promise<JsTable> keyTable = makeKeyTable();
AbortController controller = new AbortController();

viewTicket = new TicketAndPromise<>(ticket, Callbacks.grpcUnaryPromise(c -> {
HierarchicalTableViewRequest viewRequest = new HierarchicalTableViewRequest();
viewRequest.setHierarchicalTableId(prevTicket.ticket());
viewRequest.setResultViewId(ticket);
keyTable.then(t -> {
if (controller.signal.aborted) {
return Promise.resolve(controller.signal.reason);
}
if (keyTableData[0].length > 0) {
HierarchicalTableViewKeyTableDescriptor expansions = new HierarchicalTableViewKeyTableDescriptor();
expansions.setKeyTableId(t.getHandle().makeTicket());
expansions.setKeyTableActionColumn(actionCol.getName());
viewRequest.setExpansions(expansions);
}
connection.hierarchicalTableServiceClient().view(viewRequest, connection.metadata(), c::apply);
UnaryResponse viewCreationCall =
connection.hierarchicalTableServiceClient().view(viewRequest, connection.metadata(), c::apply);
controller.signal.addEventListener("abort", e -> viewCreationCall.cancel());
return null;
}, error -> {
c.apply(error, null);
return null;
});
}).then(result -> {
if (controller.signal.aborted) {
return Promise.reject(controller.signal.reason);
}
ClientTableState state = new ClientTableState(connection,
new TableTicket(viewTicket.ticket().getTicket_asU8()), (callback, newState, metadata) -> {
callback.apply("fail, trees dont reconnect like this", null);
Expand All @@ -389,6 +401,7 @@ private TicketAndPromise<ClientTableState> makeView(TicketAndPromise<?> prevTick
@Override
public void release() {
super.release();
controller.abort();
then(state -> {
state.unretain(JsTreeTable.this);
return null;
Expand Down

0 comments on commit ee6c53f

Please sign in to comment.