From 7a97b9a3f1ee7404ffde975b1c69e4e1fc5ec448 Mon Sep 17 00:00:00 2001 From: Mikael Grankvist Date: Wed, 8 Jan 2025 13:17:59 +0200 Subject: [PATCH] fix test server response format server --- .../java/com/vaadin/client/communication/MessageSender.java | 6 ++++++ flow-client/src/test/frontend/FlowTests.ts | 2 +- .../vaadin/flow/server/communication/ServerRpcHandler.java | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java index f9d951324ee..8dc9eb0463c 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java @@ -231,6 +231,12 @@ private void sendPayload(final JsonObject payload) { payload.put(ApplicationConstants.CLIENT_TO_SERVER_ID, clientToServerMessageId++); + if (!registry.getRequestResponseTracker().hasActiveRequest()) { + // Direct calls to send from outside probably have not started + // request. + registry.getRequestResponseTracker().startRequest(); + } + if (push != null && push.isBidirectional()) { // When using bidirectional transport, the payload is not resent // to the server during reconnection attempts. diff --git a/flow-client/src/test/frontend/FlowTests.ts b/flow-client/src/test/frontend/FlowTests.ts index 778c4137131..24b4edcf0ec 100644 --- a/flow-client/src/test/frontend/FlowTests.ts +++ b/flow-client/src/test/frontend/FlowTests.ts @@ -748,7 +748,7 @@ function stubServerRemoteFunction( handlers.leaveNavigation(); } } - req.respond(200, { 'content-type': 'application/json' }, 'for(;;);[{}]'); + req.respond(200, {'content-type': 'application/json'}, 'for(;;);[{"syncId":' + (payload["syncId"] + 1) + ',"clientId":' + (payload["clientId"] + 1) + '}]'); }); } diff --git a/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java b/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java index a9a8a7166ad..1b07e9466d7 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/communication/ServerRpcHandler.java @@ -131,9 +131,9 @@ public RpcRequest(String jsonString, boolean isSyncIdCheckEnabled) { clientToServerMessageId = (int) json .getNumber(ApplicationConstants.CLIENT_TO_SERVER_ID); } else { - if(!isUnloadBeaconRequest()) { - getLogger().warn( - "Server message without client id received"); + if (!isUnloadBeaconRequest()) { + getLogger() + .warn("Server message without client id received"); } clientToServerMessageId = -1; }