From ec0d28cadd5c55f5caa5a9bda5d781ea07330efc Mon Sep 17 00:00:00 2001 From: denihs Date: Wed, 26 Jun 2024 14:08:50 -0400 Subject: [PATCH] - use Meteor._debug instead of console.warn - add comments to not change the behavior of withValues() (client) --- packages/ddp-client/common/livedata_connection.js | 2 +- packages/meteor/dynamics_browser.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ddp-client/common/livedata_connection.js b/packages/ddp-client/common/livedata_connection.js index 8f87029185..2bb18d4ab0 100644 --- a/packages/ddp-client/common/livedata_connection.js +++ b/packages/ddp-client/common/livedata_connection.js @@ -614,7 +614,7 @@ export class Connection { stubOptions.stubReturnValue = DDP._CurrentMethodInvocation .withValue(invocation, stubInvocation); if (Meteor._isPromise(stubOptions.stubReturnValue)) { - console.warn( + Meteor._debug( `Method ${name}: Calling a method that has an async method stub with call/apply can lead to unexpected behaviors. Use callAsync/applyAsync instead.` ); } diff --git a/packages/meteor/dynamics_browser.js b/packages/meteor/dynamics_browser.js index 6436a3f9b9..ea1bbbc524 100644 --- a/packages/meteor/dynamics_browser.js +++ b/packages/meteor/dynamics_browser.js @@ -35,6 +35,10 @@ EVp.getOrNullIfOutsideFiber = function () { * @returns {any} The return value of the function */ EVp.withValue = function (value, func) { + // WARNING: Do not change the behavior of this function. + // If you compare this function to it's version in the server-side, you'll see that there we handle async results. + // In the client we don't need to do this. If we try to, it can lead to problems like this: + // https://github.com/meteor/meteor/pull/13198#issuecomment-2181254734/. var saved = currentValues[this.slot]; try {