-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncWrap for LTS Argon #59
Comments
In the past we have been able to get stats and how often an api is used in user land, I think it was @orangemocha or @ChALkeR If we can get a list of modules that rely on the undocumented API we could run citgm against them |
Sorry, just to be clear—AsyncWrap is already in v4.x but as @trevnorris has been improving it the API has been shifting and breaking, we just haven't been labeling with semver-minor/major for any of it yet. The comment about parity with v5.x/master is that it's already diverged (i.e. nodejs/node#3461) and may continue to do so until final. We could end up in a state where it's a different API on v4.x than master. |
The API is feeling pretty good to me. There are a couple things that could be done to make it more future proof (e.g. pass an object to setupHooks() instead of functions), but other than that I think future enhancements can be made without semver-major API changes. That is, if what's currently in master plus those few additional changes mentioned here land in v4. Now, there are two big features that people have wanted, but haven't proceeded with because don't want to spend the time writing these again if they won't be accepted. Those are:
These should be possible to do without breaking the API, but also are completely additive. I write these two as an example of what may be coming, and how it may affect LTS. |
/cc @nodejs/tracing |
@thealphanerd there is a list of all
Both of those are mine and I would much prefer getting breaking updates, than no updates. @trevnorris If you don't think any of the handle context issues listed in nodejs/diagnostics#29 will be API breaking, then I'm okay with freezing the API in node 4.x, assuming we will still get fixes. But I would like to see a clear strategy for how native modules should interface with AsyncWrap. Fixing timers, would as such be breaking. I'm currently monkey-patching the timers functions and ignorering the |
@AndreasMadsen Making class AsyncWrap : public ObjectWrap {
class Callbacks {
public:
virtual ~Callbacks() {}
virtual void Init(Local<Object> context, int64_t id, int provider, Local<Object> parent) = 0;
virtual void Pre(Local<Object> context) {}
virtual void Post(Local<Object> context) {}
virtual void Destruct(int64_t id) {}
AsyncWrap* Instance();
};
void SetCallbackHandler(Callbacks* cb); This will allow the user to receive the same callbacks that JS receives. Thoughts? |
@thealphanerd
The data is more than two months old, based only on latest versions (at 2015-09-21) of npm packages and there could be false negatives. I will update the dataset, but a bit later (not this week). |
So it would seem to me like there should be no immediate or obvious problem. Since 4.x has another 29 month's to go I think we would all benefit quite a bit from keeping apis as consistent as possible |
@trevnorris I'm not sure we are talking about the same thing, I'm talking about an replacement for the |
Another problem with Right now very few people knows about |
For the LTS group, this is the current issue tracker: nodejs/diagnostics#29 |
I think adding documentation to LTS would be a step too far. |
@AndreasMadsen Ah yes, in that case the public AsyncWrap class would do the trick. With the PR I'll add tests demonstrating how this is to be used, and can suppliant with additional documentation. As far as multiple calls to |
@trevnorris That is a huge mistake and I speak from experience. I love that node.js keeps things simple, but simplicity shouldn't be prioritized over modularity. Yes modularity can be done in userland, but it only works when there are 100% adoption. That will never happen for a userland module, that is why it needs to be in core. I speak from experience because the same issue exists with
however it is impossible for me to get 100% adoption. Overwriting Having a single modular interface in core, will create a much better ecosystem. I think that is worth the price of some complexity in core. I had hoped to do this discussion later, when |
@AndreasMadsen But there's still a key different between what you've described and what happens with AsyncWrap callbacks. In all callback cases the object instance is set as the context. Any user can then manipulate the instance. There could equally be conflicting assignments that lead to undefined behavior. The difference is that this case is more cryptic to debug. This is a topic I've entertained, and even prototyped, but every time I do I find it easy to clobber something unexpectedly. I'd like to bring this up with the CTC for discussion and get their feedback. |
Discussion topic for @nodejs/ctc: Allow single set of hooks, or multiple sets of hooks to be passed to |
As for user land stats, doesn't continuation-local-storage use it if --harmony flag is on? CLS had 122K+ downloads last month. Also, Strongloop is contemplating deprecating their use of a Context (which I hope they don't), because of the current reliability issues related to what hopefully an improved async_wrap with solve. Loopback uses CLS as well. I'm dying for a reliable async_wrap and context across asyc boundaries. To me, it's one of (the few) weaknesses of Node compared to other more established server-side run-times. |
AFAIK, cls uses async-listener, not async-wrap.
This is a digression, but I don't think async_wrap can solve the user-space queuing issues that break continuation-local-storage. |
Sorry for the digression. Isn't AsyncListener an API for AsyncWrap? |
I worked with NR developing AsyncListener. In the end the entire user interface was removed (ref nodejs/node-v0.x-archive#8110). The decision was we didn't want to introduce another "domain" issue (also attempted nodejs/node-v0.x-archive#6011) where we tied ourselves into an API that we couldn't get out of. Currently NR uses a shim that emulates AsyncListener. After sinking a good part of 3 months into it, stepped back from it and have only been incrementally working on it since then.
Technically async-listener should be using async-warp. |
CTC discussion suggested that AsyncWrap should be brought up to parity with the final version, just not announced as a public and supported API in v4. |
Topic for discussion, potential WG meeting agenda item. Coming out of nodejs/node#3461 /cc @thealphanerd, @trevnorris.
A quick report from @trevnorris on its status and how close to final(ish) it is would be helpful here.
The text was updated successfully, but these errors were encountered: