From 47ed012b0fdf5fedb198ff345e4768bda574d6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 5 Mar 2024 11:51:33 +0100 Subject: [PATCH] ensure the operation method msg is run after the client result to match 2.x behavior --- packages/ddp-client/common/livedata_connection.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/ddp-client/common/livedata_connection.js b/packages/ddp-client/common/livedata_connection.js index 395da44ac9..3a36227272 100644 --- a/packages/ddp-client/common/livedata_connection.js +++ b/packages/ddp-client/common/livedata_connection.js @@ -850,7 +850,17 @@ export class Connection { } // If we added it to the first block, send it out now. - if (self._outstandingMethodBlocks.length === 1) methodInvoker.sendMessage(); + if (self._outstandingMethodBlocks.length === 1) { + if (callback && future) { + // Ensure the method message after the result of the method ran in the client. + future = new Promise((resolve) => { + methodInvoker.sendMessage(); + resolve(); + }); + } else { + methodInvoker.sendMessage(); + } + } // If we're using the default callback on the server, // block waiting for the result.