-
Notifications
You must be signed in to change notification settings - Fork 63
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
use invalid to check asyncState #27
Conversation
@tom-pytel can you please take a look? |
see also #22 |
So if I understand this correctly it is a fix for a bug in |
Also, I don't see |
According to @Qard's reply comment this feature should be regarded as a feature rather than a bug. Maybe this is the expected behavior of enterWith. I guess it may be related to the order of calling |
According to my understanding, it will not be broken in theory, because it will be marked only when the trace ends. The subsequent span should use the new trace. Could it be said that after the Similarly, I think the role of the |
Ok, I understand what you are getting at but in that case you should be adding the invalid flag to the |
OK, I will update later |
@tom-pytel I have pushed changes, please take some time to review, thx |
Looks good. |
Actually there may still be a potential problem since the asyncState may be inherited and invalidating the state may affect a parent. I may need to dup the invalid flag like the spans are duped in |
Never mind, unnecessary since the entire |
Just saw I was tagged in here. I just wanted to say, as the author of The official interface is |
Well, apart from this bug so far it seems to be working ok after some stress testing we did. |
Quite possibly, yes. As indicated in the docs, it applies for the entire remainder of the current tick, which isn't necessarily the span you think it is. In cases like event batching it can cause all sorts of havoc because, as shown in the docs, it will leak from one event emission into the next if they are triggered within the same tick. There's no logical boundary around |
I understand what you mean by this and I did test to verify how it behaves (event handlers and all). I take this into account and specifically code around it by doing things like cloning the context object in child tasks, including a mutable array of spans in order to not modify the parent. Also explicitly removing the current span from the list of spans if the span code is about to relinquish control to be regained in a new async task and re-adding to the list of spans there in order that chronologically subsequent siblings in the same task do not become children (does that explanation make sense?). It seems to work.
The logical boundary in this case is somewhat convoluted because of the open-ended control flow with
This is a risk, but I do not have much choice here. Like I said, |
After testing, if two requests are repeatedly sent in a short time, the subsequent requests may use the
AsyncState
initialized by the previous request. It is temporarily unclear whystore.enterWith(undefined as unknown as AsyncState)
in theclear
method not work(The store cannot be reset), I tried to add aninvalid
flag, which works normally, I hope to discuss the feasibility of this implementation with you, thx