-
-
Notifications
You must be signed in to change notification settings - Fork 27
refactor: centralize into functions #377
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
base: main
Are you sure you want to change the base?
Conversation
| * @returns {Promise<void | never>} | ||
| */ | ||
| async function runElmReviewInWatchMode() { | ||
| async function runElmReviewInWatchMode(options, errorHandler) { |
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 keep meaning to circle back to this. Unrelated to this change, the recursive nature of this function means I think it leaks memory and could potentially stack-overflow. Or just have bad stacktraces.
Related to this diff, because references to options & errorHandler now need to passed down and stored on the stack of every recursion, I think this change effectively ⅓s the number of saves elm-review can run it watch mode before crashing. It should still be an absurdly large number, but could be a potential issue?
Then again, I could have just misread the code or perhaps v8 does more optimization to recursion than I think it does.
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.
Copilot informed me that asynchronous recursion doesn’t stack-overflow (i.e., callbacks that are in new event loop ticks have new stacks), so that’s not an issue, but passing in options might leak memory.
StackOverflow agrees, so putting that as LARGE WARNING against merging this.
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.
Alright, I won't merge the PR in the current state then. The other changes (look good though to be clear).
Maybe we should just revisit this function's implementation entirely (I can't right now though, upcoming vacation), though that's probably easier said than done, I haven't looked at the function in a long time.
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, did some more investigation, and I think it's fine... not really sure how to double-check that though.
17ff53a to
8a02c2c
Compare
c90da54 to
23f2a87
Compare
23f2a87 to
e1cfd62
Compare
Stop running stuff on module evaluation, instead run it on executing
main().Depends on #380.