-
Notifications
You must be signed in to change notification settings - Fork 80
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
add error stack to .later
#250
Conversation
as mentioned here emberjs/ember.js#15215 |
3e59a17
to
ec74625
Compare
awesome, i like this direction! |
85a6281
to
4d4cd37
Compare
lib/index.ts
Outdated
let method = timers[i + 3]; | ||
let args = timers[i + 4]; | ||
let stack = this.DEBUG ? new Error() : undefined; | ||
this.currentInstance.schedule(defaultQueue, target, method, args, false, stack); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not using _ensureInstance()
here because we are already in run loop
only brittle part is: I am identifying timerId type by its value type, if it is |
3f60385
to
2f73044
Compare
this looks good, no ? :) |
this is good to go if something :P |
I resolved the conflicts from recent changes. @stefanpenner - Mind taking another look? |
@stefanpenner can this be merged :) this might help to further refactor |
c9457a8
to
5617435
Compare
06777b3
to
af8f9ad
Compare
lets merge this 📣 😛 |
@rwjblue maybe we should merge this :) |
af8f9ad
to
06cfa0d
Compare
@stefanpenner thoughts ? |
06cfa0d
to
f68845e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased this to get latest updates to build and linting, which pointed out a type issue that I also pushed a commit fixing.
I also pointed out an issue inline around where the debug stack is being captured. I'll try to take a stab at fixing that if I have a chance. Otherwise this looks great...
lib/index.ts
Outdated
let target = timers[i + 2]; | ||
let method = timers[i + 3]; | ||
let args = timers[i + 4]; | ||
let stack = this.DEBUG ? new Error() : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being done in the wrong place. _scheduleExpiredTimers
is after the real setTimeout
has ran and we are scheduling the jobs into the actions queue. That will mean the debug stack we are grabbing here is now the stack from where run.later(...)
was called.
This needs to be moved into _setTimeout
where we are doing this._timers.splice(...)
/ this._timers.push
so that the captured debug stack is the "right" place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, pushed a fix for this issue to the branch along with a test...
Add tests ensuring stack capture works properly.
Fixed this, and added a test confirming things work nicely. |
.later
as in.schedule
.scheduleOnce
....later
callback(there is 5% drop inLater & Cancel - function, target
case benchmark)any thoughts ? if you like the idea will squash and cleanup