-
Notifications
You must be signed in to change notification settings - Fork 72
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 "EOFError error" when using webpack dev server over HTTPS #113
Fix "EOFError error" when using webpack dev server over HTTPS #113
Conversation
raise | ||
end | ||
dev_server_asset(@asset_path) | ||
elsif Webpacker.config.public_path.present? |
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 wonder if we can get rid of this check. I can't think of a scenario where an application using webpacker would not have Webpacker.config.public_path
configured. 🤔
It would probably be a good idea if the folks from #101 and #111 could verify that this change does not break their setup... cc @connorshea @jclusso @moxie @dennmart @agrobbin @jamesmartin (Sorry about all the mentions — just want to ensure I didn't break your development environments!) |
def fetch_from_dev_server(file_path) | ||
http = Net::HTTP.new(Webpacker.dev_server.host, Webpacker.dev_server.port) | ||
http.use_ssl = Webpacker.dev_server.https? | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE |
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.
VERIFY_NONE
should be sufficient here, since the webpack dev server should be run in development environments only.
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 don't have a strong opinion about this one because I'm not heavily using Webpacker in any projects right now. I'm a little concerned how large and complex this file is getting without any tests.
I've been considering writing up some integration tests that spin up actual Rails projects (different versions) and do some basic smoke tests, otherwise I have to do this all manually. 🤔
💯 agree. I started going down the path of refactoring this file (largely to make it easier to test) but it felt beyond the scope of this PR. I was going to mock Integration tests would be hugely beneficial. I don't have much experience writing them though, and don't really even know where to start testing multiple Rails apps 😕 Maybe Appraisal could help with this? In the meantime, I'd be happy to add some unit tests using mocks, if you think that would be helpful. |
Thanks for the tip, I'll take a look at Appraisal. ✨
I think some unit tests would be helpful to clarify our intentions, even with the problems associated with using Mocks. I would appreciate it, if you don't mind adding some. 👍 |
I've generally found that using rails generator scripts can be useful, it's what we do in sorbet-rails. Unfortunately they require either committing the app(s) to the repo or generating them every time you run the test suite, neither of which is really ideal. |
Just tested it in my app and it seems to work fine, adding a new SVG works fine and everything. |
Mocking Webpacker, Rails, and network requests is proving to be more complex than I anticipated 😓 You can see what I've got so far — it's ugly: kylefox@17ca964 Let me know if you want me to continue down this path. It may be better to introduce tests (including integration tests) against Webpacker/Rails directly in a new pull request. However, I probably won't have time to tackle this myself. 😕 |
24d27e0
to
9940431
Compare
Yeah, I see what you mean. Do you feel like these tests are worth having or would just be brittle overhead? 🤔
I started playing with this idea in a separate repo that I maintain to manually test the gem on different versions of Rails. You can see that the integration tests I was able to write are fairly comprehensive and I was able to get the tests running on rails3, rails4, rails5 and rails6 with Sprockets. The tests for the rails6-webpacker branch are currently broken because of a configuration problem but I think they should be fixable. I'm wondering if we could use the integration tests for my test app as the integration tests for this gem somehow. I'll think more about how that might work. 🤔 |
The tests for the rails6-webpacker branch is working now, so I feel pretty good about the test coverage in that repo. @kylefox I think we could probably do without the brittle unit tests for this code if you're happy with it. |
I've setup integration tests against five different Rails versions. The workflow is kind of gnarly and there's an example of them all passing. @kylefox if you update this branch with the latest changes from |
9940431
to
d232345
Compare
@jamesmartin Cool, I just rebased this branch against |
Thanks again for your work on this, @kylefox. ✨ I've merged your PR and will hopefully make a new patch release in the next week or so. |
Awesome, thanks so much! |
Hey @jamesmartin, just wanted to bump this 🙂 Would it be possible to release a patch version with this fix? |
This PR fixes an
EOFError: end of file reached
error that occurs when runningwebpack-dev-server
over HTTPS (related to the recent changes introduced in #111).