Description
In current proposal snapshot()
is a static method capturing full context of all AsyncContext
variables.
As a result snapshot.run()
impacts all AsyncContext
users.
This differs from asyncVar.run()
usage where current context entries for other asyncVar
instances are not impacted.
This global context restore sounds reasonable for library authors (or runtime internally) which knows and defines the global context flow. For example restoring JS context after interacting with some scheduling outside of JS (e.g. interacting with OS sockets,...).
But with the discussions ongoing in #83 or AsyncContext.callingContext()
I'm not that sure if this global snapshot/restore is a good thing in general.
Once some AsyncContext
user starts to call snapshot()
to customize/tune it's context flow it might break other users.
Not sure a an instance snapshot()
API is the way to go. Maybe it is more a doc topic to tell users to prefer const myData = asyncVar.get()
and asyncVar.run(myData)
instead snapshot()
.