Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix failed server restart calling integration hooks twice #7917
Fix failed server restart calling integration hooks twice #7917
Changes from 1 commit
7b08bee
c0e35b1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why move this out of the package? I think this function is sort of implementation detaily
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.
It's only used by tests and I'm not really a fan of putting tests related logic in the source code 😬
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.
If this were a class with a
isStarted
method would you feel that way too?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.
Yeah, right now the
Container
concept has things likehandle()
, andRestart
(container) has therestarted
property, which are only used in tests, and it feels like we're prying out internal implementation for restarting so we can unit test it.I also realized the unit tests wasn't testing things right (e.g. invalid config error), plus uses hacky methods like:
astro/packages/astro/test/units/dev/restart.test.js
Lines 68 to 72 in 6806629
which is not so great. I think server restarts as a feature is a user experience, and it should've been tested through e2e in the first place. Sorry for going into a rant 😅 I've been slowing trying to fix these e.g. in the recent config refactors.
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.
Yes, we are! Testing is very important here, we had a lot of HMR bugs prior to this refactor and now we see very few. So pretty or not, it was a success.
And although these things are not currently exposed as APIs doesn't mean they won't or shouldn't be. A server being able to restart itself seems like a pretty essential feature. Real production servers like Apache and Nginx have these APIs.
e2e tests would be much slower though. As developers on libraries/frameworks we have to take on ugly/not great code so that our users can write clean code themselves. Always remember that for us the order of priority is:
We have to do some ugly things because the libraries we depend on (Vite in this example) are themselves not designed to be testable. We can't let our libraries dictate that we not be as well.
But, this is a bit of a sidebar, happy to keep talking about it elsewhere 😀. Would love to have this API improved and be less ugly as long as we don't sacrifice test exhaustion or speed in order to do so.
For this particular change I don't see a problem with removing the
isStarted
function since we're not longer using it and, as you pointed out, we already are reaching into some internals for the tests anyways.