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
Cancel the active request instead of the most recent request #2696
Conversation
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'm really impressed, brilliant work 👏
I am unsure about ui or module tests. Is there something I should add?
Currently there are no UI tests (this is WIP as I'd like to add them too).
Some tests could potentially be added for the cancelRequestById
function in network.test.js
though. Looks like there are only tests for _actuallySend
, which sets up the cancellation logic, so we might be able to add a few test cases to also cancel.
Give that a go, and if it's non-trivial to add tests for cancellation then I'll merge this in as-is. Looks pretty good to me!
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.
Small change about clearing the cancel function once a request completes or is cancelled, to avoid a memory leak 😄
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.
Your update to the unit test was exactly what I had in mind, nice work!
A couple of comments, almost there 🤗
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.
Nicely done 💯
I did some manual testing:
Cancel functions didn't persist longer than necessary. So excited to merge this! |
@develohpanda thanks for reviewing and advising. I appreciate this. |
Credit where credit is due, @DMarby noticed the memory leak, and you did a great job with fixing it up. I was certainly impressed with your refined unit test as well! 🥇 |
Closes #2690
I replaced the inner network.js variable cancelRequestFunction with a Map that remembers the requestId of the given cancelFunction.
Also the ui now uses cancelRequestById with the actual requestId to cancel the specific request.
I tested package insomnia-app locally via ui with the express based test-server that was proposed by the issue description (very helpful and precise by the way).
I also ran all tests with
npm test
locally from repository root...all seem fine.I am unsure about ui or module tests. Is there something I should add?