Skip to content
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

Asset helpers should not call Webpacker.dev_server.running? in production #1173

Closed
javan opened this issue Jan 12, 2018 · 3 comments
Closed

Comments

@javan
Copy link
Contributor

javan commented Jan 12, 2018

Webpacker.dev_server.running? opens a socket connection:

def running?
Socket.tcp(host, port, connect_timeout: connect_timeout).close
true
rescue
false
end

That's fine for development mode, but no good for production.

def asset_pack_path(name, **options)
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?

def asset_pack_url(name, **options)
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?

def stylesheet_pack_tag(*names, **options)
unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?

Introduced in #641 and #1172.

/cc @dhh @gauravtiwari

@gauravtiwari
Copy link
Member

Good spot 👍 think we need to bypass this check altogether in production or make this block development specific only?

unless Webpacker.env.development? &&  Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?

@javan
Copy link
Contributor Author

javan commented Jan 12, 2018

That would work, I suppose. Probably time for a new helper to encapsulate that condition. Another option is to have Webpacker::DevServer#running? return false unless env.development?.

@dhh
Copy link
Member

dhh commented Jan 13, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants