From 5bd68b6a4fb82aaebb4edbf71b6d69bedf4fa79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 8 Apr 2024 17:57:04 +0200 Subject: [PATCH] re-run checks --- packages/meteor/dynamics_browser.js | 1 - packages/meteor/dynamics_nodejs.js | 22 +++++------ packages/meteor/dynamics_test.js | 57 ++++++++--------------------- 3 files changed, 26 insertions(+), 54 deletions(-) diff --git a/packages/meteor/dynamics_browser.js b/packages/meteor/dynamics_browser.js index 438857314b..13133c2776 100644 --- a/packages/meteor/dynamics_browser.js +++ b/packages/meteor/dynamics_browser.js @@ -42,7 +42,6 @@ EVp.withValue = function (value, func) { } finally { currentValues[this.slot] = saved; } - return ret; }; diff --git a/packages/meteor/dynamics_nodejs.js b/packages/meteor/dynamics_nodejs.js index 4a81bf7ba8..bdb147ca83 100644 --- a/packages/meteor/dynamics_nodejs.js +++ b/packages/meteor/dynamics_nodejs.js @@ -49,22 +49,20 @@ class EnvironmentVariableAsync { */ withValue(value, func, options = {}) { const self = this; - const slotCall = self.slot; - const dynamics = Object.assign( - {}, - Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {} - ); - - if (slotCall) { - dynamics[slotCall] = value; - } - + const slotCall = Meteor._getValueFromAslStore(SLOT_CALL_KEY); + const dynamics = + Meteor._getValueFromAslStore(UPPER_CALL_DYNAMICS_KEY_NAME) || {}; + dynamics[slotCall] = Meteor._getValueFromAslStore(CURRENT_VALUE_KEY_NAME); + self.upperCallDynamics = dynamics; return Meteor._runAsync( async function () { let ret; try { + Meteor._updateAslStore( + UPPER_CALL_DYNAMICS_KEY_NAME, + this.upperCallDynamics, + ); Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, value); - Meteor._updateAslStore(UPPER_CALL_DYNAMICS_KEY_NAME, dynamics); ret = await func(); } finally { Meteor._updateAslStore(CURRENT_VALUE_KEY_NAME, undefined); @@ -82,7 +80,7 @@ class EnvironmentVariableAsync { [SLOT_CALL_KEY]: this.slot, }, options, - ), + ) ); } diff --git a/packages/meteor/dynamics_test.js b/packages/meteor/dynamics_test.js index 3d5763e7d1..c7fe023c85 100644 --- a/packages/meteor/dynamics_test.js +++ b/packages/meteor/dynamics_test.js @@ -16,52 +16,27 @@ Tinytest.add("environment - dynamic variables", function (test) { test.equal(CurrentFoo.get(), undefined); }); -if (Meteor.isServer) { - Tinytest.addAsync( - "environment - dynamic variables with two context (server)", - async function (test) { - const context1 = new Meteor.EnvironmentVariable(); - const context2 = new Meteor.EnvironmentVariable(); +Tinytest.addAsync( + "environment - dynamic variables with two context", + async function (test) { + const context1 = new Meteor.EnvironmentVariable(); + const context2 = new Meteor.EnvironmentVariable(); - return context1.withValue(42, async () => { - test.equal(context2.get(), undefined); - await context2.withValue(1, async () => { - await context2.withValue(2, async () => { - test.equal(context2.get(), 2); - }); - test.equal(context1.get(), 42); - test.equal(context2.get(), 1); + await context1.withValue(42, async () => { + test.equal(context2.get(), undefined); + await context2.withValue(1, async () => { + await context2.withValue(2, async () => { + test.equal(context2.get(), 2); }); test.equal(context1.get(), 42); - test.equal(context2.get(), undefined); + test.equal(context2.get(), 1); }); - } - ); -} else { - // Basically the same test as the server one, but without async/await - // as we don't handle async on the client in this case - // due to the idea that we need to keep new EcmaScript features doesn't compile in older browsers - Tinytest.add( - "environment - dynamic variables with two context (client)", - function (test) { - const context1 = new Meteor.EnvironmentVariable(); - const context2 = new Meteor.EnvironmentVariable(); + test.equal(context1.get(), 42); + test.equal(context2.get(), undefined); + }); + } +); - context1.withValue(42, () => { - test.equal(context2.get(), undefined); - context2.withValue(1, () => { - context2.withValue(2, () => { - test.equal(context2.get(), 2); - }); - test.equal(context1.get(), 42); - test.equal(context2.get(), 1); - }); - test.equal(context1.get(), 42); - test.equal(context2.get(), undefined); - }); - } - ); -} Tinytest.addAsync("environment - bindEnvironment", async function (test) { var raised_f;