Comments (2)
These tests demonstrate the current behaviors and expected support in Meteor 3.0.
In your example, code might need adjustment to ensure you properly await children asyncs to maintain the env variable context. For instance:
let ev1 = new Meteor.EnvironmentVariable();
async function runAsyncFunction() {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('value2', ev1.get());
}
ev1.withValue({ name: 'test' }, () => {
➡️ await runAsyncFunction();
console.log('value 1', ev1.get());
});
With this you get the proper response.
value 1 { name: 'test' }
value2 { name: 'test' }
I also tried it on the test we have.
While achieving this might be possible, given my limited familiarity with this code or Async Local Storage behavior, further exploration is needed. Otherwise, this change could be a breaking change caused by the way async operations behave in the new Meteor 3.x.
Thank you for bringing it to our attention.
cc @denihs
from meteor.
Preserving the env vars in async child contexts was an important part of the implementation in Meteor 1/2. Meteor wrapped most callback api's with Meteor.bindEnvironment, and had code in the promise
package to preserve the env var values in async functions and promises. Since ALS works the same, it seems this behavior is generally expected.
You should be able to simply remove these lines. ALS makes the store available to all child resources, so if you don't mutate it it will work the same as in Meteor 1/2. There's no need to unset UPPER_CALL_DYNAMICS_KEY_NAME
- you're creating a new store object each time, so outside code isn't able to read it (earlier implementations didn't create a new object, which is probably why the code was added).
When working on using ALS in montiapm:agent
, I found it helpful in my understanding to read Node's source code for ALS.
from meteor.
Related Issues (20)
- Unable to create new meteor 3 projects HOT 4
- why am i getting this isses, please someone help. FormData { file name → {} } HOT 2
- Idle Crash in Development Mode
- Meteor 3 Migration Guide Feedback
- [Meteor 3] Tinytest major version increased HOT 2
- [Meteor 3] EnvironmentVariable.withValue has different return value on client and server
- [Meteor 3] SyntaxError: Unexpected token 'export' HOT 2
- bundle-visualizer not working with Meteor 3
- Login and CreateUser method send back the added message without fully fields HOT 2
- Meteor3 - MultiFileCachingCompiler does not set up its internal LRU cache correctly HOT 10
- Allow-deny package does not parse MongoServerError
- meteor/reify - changelog is not up to date HOT 1
- Method only runs once on server, simulation on client does run - 3.0-rc.0 HOT 4
- Firefox iOS is not marked as a modern brower HOT 5
- Meteor: 3.0.0-rc1 Package: allow-deny -> client side collection insert/update/remove not working as expected HOT 2
- I have a issue Cannot convert undefined or null to object TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at generateGridColumns (http://localhost:3000/main.e952596e505304fc7155.hot-update.js:41:30) HOT 2
- [Meteor 3] "meteor node" use the old node 14 instead of 20 HOT 1
- [Meteor 3] React regression: Warning: Invalid hook call. Hooks can only be called inside of the body of a function component.
- Missing Update for Meteor 3.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor.