phoenixframework / phoenix_live_reload Goto Github PK
View Code? Open in Web Editor NEWProvides live-reload functionality for Phoenix
License: MIT License
Provides live-reload functionality for Phoenix
License: MIT License
Is there a reason that phoenix_live_reload uses the 0.9.x branch of the fs module? Reason I ask is that the 0.9.x branch doesn't seem to work in Docker properly whereas the 2.12.x branch does. This is a problem for presumably all watch type tools that need to be installed alongside phoenix_live_reload (lpil/mix-test.watch#61 for example).
Alternatively I'm going to have a peek at the fs module and see if I can spot what the problem is exactly and try to formulate some kind of work around, but it'd be nice to be able to not worry about it :)
It does work but only when started from phoenix app directory: (cd apps/example_web && iex -S mix phoenix.server
). Example repo: https://github.com/wojtekmach/gettext_umbrella/tree/master/apps
I have a phoenix 1.4-dev umbrella app that was working in live reload mode in dev until recently, maybe 4 weeks or so
the structure is thus
web_1
web_2
web_3
db
when live reload is turned off the entire umbrella app will run
when live reload is on and I run MIX_ENV=dev iex -S mix phx.server within web_x folder live reload works
I havent got a public demo codebase for this
(I think also Distillery is also broken in this config, havent checked it yet)
I thinking I am running all the latest packages
See http://stackoverflow.com/questions/34773779/does-phoenix-code-reloader-only-reload-elixir-code
It's not clear what this repository does in comparison with Phoenix.CodeReloader
It seems that with v1.0.4, earmark is introduced as a hard requirement.
Just checking, is it a hard requirement, or it's supposed to be required only under :docs, similar to ex_doc
?
So we avoid accidentally exposing it in prod.
Is there a way to specify what folders are watched? It seems I'm not getting reloads when I edit my:
lib/my_app/i18n/en.ex
file inside of Phoenix.
In the JavaScript portion of this project, the pageStrategy
scheme causes a reload using window.top.location.reload()
(see here). This makes sense, as the JavaScript itself is running inside of an iframe
.
However, I'm curious if there was a specific motivation for using window.top
rather than window.parent
. We load the Phoenix application in another iframe
(for good reasons I can share if necessary); thus the window.top
escapes one too many levels and reloads more than necessary.
Ours is definitely a special use-case, and we're prepared to create & maintain a fork of this project to support it. However, it would be nice to know if there are any edge cases or other considerations we may be missing.
Thank you for your time!
/cc @parkerl as the committer of the relevant line
As it depends on "file_system" it also supports OpenBSD and FreeBSD.
With this commit in Phoenix: phoenixframework/phoenix@3f6df5d
Generating a new application from master, causes the following error:
Unchecked dependencies for environment dev:
* phoenix (https://github.com/phoenixframework/phoenix.git)
the dependency phoenix in mix.exs is overriding a child dependency:
> In mix.exs:
{:phoenix, nil, [git: "https://github.com/phoenixframework/phoenix.git"]}
> In deps/phoenix_live_reload/mix.exs:
{:phoenix, "~> 0.16 or ~> 1.0", [only: :dev, optional: false, hex: :phoenix]}
Ensure they match or specify one of the above in your deps and set "override: true"
** (Mix) Can't continue due to errors on dependencies
My best guess of what is happening:
Generating a new Phoenix application points to Phoenix master,
and Phoenix Live Reload depends on a Phoenix version between "~> 0.16 or ~> 1.0"
I made a PR #25 pointing to Phoenix master and that seems to solve the issue.
It seems like this could also could be solved by a patch level Phoenix release.
I wrote some codes, they were built succeeded and output into ./priv/static/script/
:
But, if I change my codes and trigger the live-hot
, sometimes the copied file in _build/dev/lib/my_app_path/priv/static/
would be cleared:
This doesn't happened every times, but I think it maybe due to the size of the file was too large and this plugin reload the file early.
I took a try, every time I clear the terminal manual and trigger reload, then record if the file in _build
directory was cleared:
First, start the server, the file was correctly and page looks well:
Clear the terminal and trigger a reload:
Repeat last step sometimes until the problem happend:
After compared those too case, we can see the different, while the logger looks like those, everything works well:
And if the log looks like those, the finally built file would be cleared:
I hope that this problem could be fixed as soon as possible, it really interfere my work, thank you.
I'm trying to use the latest version of the phoenix framework and I'm having some issues. I can't compile the dependencies when using the latest version of the phoenix_live_reload package, everything works if I downgrade to v1.0.6.
This is the error I'm getting:
~ mix deps.compile
===> Package <<"pc">> not found. Fetching registry updates and trying again...
===> Plugin pc not available. It will not be used.
===> Package <<"rebar3_hex">> not found. Fetching registry updates and trying again...
===> Plugin rebar3_hex not available. It will not be used.
===> Package <<"pc">> not found. Fetching registry updates and trying again...
===> Plugin pc not available. It will not be used.
===> Package <<"rebar3_hex">> not found. Fetching registry updates and trying again...
===> Plugin rebar3_hex not available. It will not be used.
===> Package <<"pc">> not found. Fetching registry updates and trying again...
===> Plugin pc not available. It will not be used.
===> Package <<"rebar3_hex">> not found. Fetching registry updates and trying again...
===> Plugin rebar3_hex not available. It will not be used.
===> Compiling fs
===> Unable to run pre hooks for 'compile', command 'compile' in namespace 'pc' not found.
** (Mix) Could not compile dependency :fs, "/Users/rcoedo/.mix/rebar3 bare compile --paths "/Users/rcoedo/Workspace/src/github.com/rcoedo/teacher/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile fs", update it with "mix deps.update fs" or clean it with "mix deps.clean fs"
Thanks!
The below code give an error: socket.chan is not a function
Should I upgrade phoenix to the latest one? I am currently using 0.12.0
Our application in production runs through a proxy with a base URL that is not "/". To emulate that in development environments we run the application under a proxy and use the :path
option of the :url
config of the endpoint to identify the root path (with appropriate updates to the router, static path locations, etc).
config :my_app, MyAppWeb.Endpoint,
url: [host: "localhost", path: "/my_app"],
This "breaks" the Phoenix.LiveReloader plug's functionality. At the heart of the breakage is that the LiveReloader creates an iframe and sets the source of that iframe to:
# from live_reloader.ex:125
defp reload_assets_tag(conn) do
path = conn.private.phoenix_endpoint.path("/phoenix/live_reload/frame")
"""
<iframe src="#{path}" style="display: none;"></iframe>
"""
end
Because it is using the endpoint information to generate the path, the source of the reload iframe is presumed to be hosted with the non-root path component added (my_app
in this case : http://localhost:4000/my_app/phoenix/live_reload/frame
)
To provide the content of that frame, however, the live_reloader
code does an explicit match on path_info
in the connection:
def call(%Plug.Conn{path_info: ["phoenix", "live_reload", "frame"]} = conn , _) do
# …more stuff here…
end
So it explicitly looks for a request to "/phoenix/live_reload/frame" at the root (it doesn't take the fact that the endpoint might be based somewhere other than root into account). As a result, the content of the frame is not loaded and the live reload functionality breaks down.
To resolve this, either the hard-coded path for the content of the iframe needs to be matched dynamically, and take the endpoint's settings into account, or the path that serves as the src
of the iframe needs to not take the endpoint settings into account.
I'm using dinghy with fsevents_to_vm to run my phoenix container. It basically touches files in the VM via ssh to force inotify events. The 0.9.1 fs version pinned in e54bf6f doesn't listen for the ATTRIB events that come out of this setup but the 2.12.0 version does.
This completely breaks live reload in my setup.
So besides umbrella projects we can use local folders containing elixir apps as deps with mix.
But this dev cycle requires:
mix.deps get
in phoenix project.Would it make sense to add mix.deps get
to phoenix_live_reload when some special config is present?
I will work on this if there are no objections.
I was working on a project tonight and encountered what appears to be a bug in which the live reload feature is preventing mix from picking up file changes. I'm able to reproduce it by doing the following:
In playing around with it, it appears as if the page reload in step 5 is what causes the problem because if you immediately shut down the server and restart it after renaming a file the helpers.ex file will be recompiled.
My deps/0
function has this line:
{:phoenix_live_reload, "~> 1.0", only: :dev},
But then when I try to start my app in prod mode with MIX_ENV=prod mix phx.server
, I get this error:
Could not start application phoenix_live_reload: could not find application file: phoenix_live_reload.app
Why is it trying to start the application in prod
when the dep lists it as a dev
only dep?
Oh, and my application/0
function only lists extra applications:
extra_applications: [:logger, :runtime_tools]
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.4.5
Thanks.
release was pushed but it looks like master is still behind.
Apparently, freebsd does not have anything like inotify, so Phoenix live reload is not working there. Inotify is a Linux kernel feature and not supported in BSD. Any workarounds?
Here the error:
Couldn't watch modify: No such file or directory
OS: Arch Linux
Kernel: x86_64 Linux 4.6.2-1-ARCH
Phoenix: v1.1.6
Mix: 1.2.6
Initial app directory contained a space, also inotifytools were not installed. Hot Code Reload was not being triggered when changes were made to /web.
After installing inotifytools, and creating a new app in the same spaced directory, reload was still not being triggered.
After creating a new parent directory and creating a new app, reload was being triggered without issues.
Likely cause: spaced-directory names in the phoenix app path
This page would display the same output as mix phoenix.routes
, but would automatically refresh whenever you change your router. It could look similar to the page Rails displays when it returns a 404 in development mode:
New routes could be highlighted when the page refreshes. Inspiration: http://phoenixroutes.herokuapp.com/
We could the same as here: https://github.com/brunch/auto-reload-brunch/blob/master/vendor/auto-reload.js#L21-L33
@parkerl, if you would like to implement this feature, please go ahead! :)
All,
I am trying to use mix_test_watch as a dependency with my phoenix project and running into version conflicts with fs.
I am getting the following error while updating my dependencies:
Failed to use "fs" (version 0.9.2) because
mix_test_watch (version 0.4.0) requires ~> 2.12
phoenix_live_reload (version 1.0.8) requires ~> 0.9.1
mix.lock specifies 0.9.2
Would it be possible to revive the phx_reloader to a more recent fs version or are there underlying issues?
Thank you!
Hey there, I had an interesting experience trying to figure out why live reload did not work. As it turns out, I accidently removed opening <body>
tag. It took some time to figure out what was wrong. Maybe we should display an error message if live reload is enabled, but the <body>
tag is missing?
After altering the :path in my phoenix project's config.exs file to:
url: [host: "localhost", path: "/newsite"],
and my endpoint.ex file to:
...
if code_reloading? do
socket "/newsite/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
...
The Phoenix.LiveReloader
plug's call function will never match on the path info.
i.e. This function definition won't match as long as the path has been prepended:
def call(%Plug.Conn{path_info: ["phoenix", "live_reload", "frame"]} = conn , _) do
I've modified this locally and it looks to be working well. I'll send a PR for your review.
Cheers,
Tony
mix.exs specifies 'or ~> 1.4' which does not match '1.4.0-rc.0', as seen when trying to mix deps.get
Failed to use "phoenix" (version 1.4.0-rc.0) because
phoenix_live_reload (version 1.1.7) requires ~> 1.0 or ~> 1.2 or ~> 1.3 or ~> 1.4 *
mix.exs specifies ~> 1.4.0-rc.0
I am currently using this in pace with phoenix master and am receiving warnings about the deprecation of transport/3
in the socket.
I understand I am running the edge and that organizing the dependency repositories is "coming soon". I have a fork where I just removed the calls to transport/3
and I updated the live reload socket declaration in my projects endpoint and its working. But I was curious if we are concerned about backwards compatibility or if semver is going to lock step everything for phoenix 1.4+
If thats the case, I can just PR my changes and we would just need to update the new project generator and docs if the socket transport layer is stable in phoenix master.
Is it possible to live-reload translation changes from other apps within an umbrella?
I'm exploring two different setups:
Translator
app that holds all translation *.po
, and other apps depend on it. At work, we're leaning towards this setup, but any recommendations are very welcome. Example repo: https://github.com/wojtekmach/gettext_umbrella/tree/translator/appsLive-reloading doesn't work in either setup.
Might be related to #40
This seems strange to me, but it appears that saving a template file using NeoVim causes the app to throw a Phoenix.Template.UndefinedError
exception. I make the exact same changes using VSCode or a plain text editor and the live reload functionality works as expected.
I installed the inotify tools as mentioned in the installation guides and ran neovim without an init.vim file as to not use any config or plugins.
Here are the steps I took:
mix phx.new lab
Fetch and install dependencies? [Yn]
cd lab && mix ecto.create && mix phx.server
nvim lib/lab_web/templates/layout/app.html.eex
I add the word Hello
right under the opening body
tag and hit :w
in neovim.
Browser refreshes in the background with this error.
[debug] Live reload: lib/lab_web/templates/layout/app.html.eex
[debug] Live reload: lib/lab_web/views/layout_view.ex
Compiling 1 file (.ex)
[debug] Live reload: lib/lab_web/templates/layout/app.html.eex
[debug] Live reload: lib/lab_web/templates/layout/app.html.eex
[info] GET /
[debug] Processing with LabWeb.PageController.index/2
Parameters: %{}
Pipelines: [:browser]
[info] Sent 500 in 26ms
[error] #PID<0.376.0> running LabWeb.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
** (Phoenix.Template.UndefinedError) Could not render "app.html" for LabWeb.LayoutView, please define a matching clause for render/2 or define a template at "lib/lab_web/templates/layout". No templates were compiled for this module.
Assigns:
%{conn: %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...}, assigns: %{layout: {LabWeb.LayoutView, "app.html"}}, before_send: [#Function<0.59940076/1 in Plug.CSRFProtection.call/2>, #Function<4.124402890/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.45862765/1 in Plug.Session.before_send/2>, #Function<1.34262281/1 in Plug.Logger.call/2>, #Function<0.832222/1 in Phoenix.LiveReloader.before_send_inject_reloader/2>], body_params: %{}, cookies: %{}, halted: false, host: "localhost", method: "GET", owner: #PID<0.376.0>, params: %{}, path_info: [], path_params: %{}, peer: {{127, 0, 0, 1}, 34494}, port: 4000, private: %{LabWeb.Router => {[], %{}}, :phoenix_action => :index, :phoenix_controller => LabWeb.PageController, :phoenix_endpoint => LabWeb.Endpoint, :phoenix_flash => %{}, :phoenix_format => "html", :phoenix_layout => {LabWeb.LayoutView, :app}, :phoenix_pipelines => [:browser], :phoenix_router => LabWeb.Router, :phoenix_template => "index.html", :phoenix_view => LabWeb.PageView, :plug_session => %{}, :plug_session_fetch => :done}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{}, req_headers: [{"host", "localhost:4000"}, {"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}, {"referer", "http://localhost:4000/"}, {"accept-encoding", "gzip, deflate, br"}, {"accept-language", "en-US,en;q=0.9,es;q=0.8,fr;q=0.7"}], request_path: "/", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "a80k8c4jv29gepvqp03ebdtspiko5csk"}, {"x-frame-options", "SAMEORIGIN"}, {"x-xss-protection", "1; mode=block"}, {"x-content-type-options", "nosniff"}], scheme: :http, script_name: [], secret_key_base: "0VOVnDiOF2VZBh4+e9liE1QP/9a1YIHbLySbbctIX7//bpKKmIHjJ6MQ8jWRaFNm", state: :unset, status: nil}, template_not_found: LabWeb.LayoutView, view_module: LabWeb.PageView, view_template: "index.html"}
Assigned keys: [:conn, :template_not_found, :view_module, :view_template]
(phoenix) lib/phoenix/template.ex:364: Phoenix.Template.raise_template_not_found/3
(phoenix) lib/phoenix/view.ex:332: Phoenix.View.render_to_iodata/3
(phoenix) lib/phoenix/controller.ex:740: Phoenix.Controller.do_render/4
(lab) lib/lab_web/controllers/page_controller.ex:1: LabWeb.PageController.action/2
(lab) lib/lab_web/controllers/page_controller.ex:1: LabWeb.PageController.phoenix_controller_pipeline/2
(lab) lib/lab_web/endpoint.ex:1: LabWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
(lab) lib/lab_web/endpoint.ex:1: LabWeb.Endpoint.plug_builder_call/2
(lab) lib/plug/debugger.ex:99: LabWeb.Endpoint."call (overridable 3)"/2
(lab) lib/lab_web/endpoint.ex:1: LabWeb.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) /home/david/dev/lab/lab/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
If I manually refresh the page, it renders with my added word in place.
I'm using
I found that sometimes live_reload is triggered before the codes being compiled. (on ubuntu 14.04)
Of course the best solution is to track the changed file properly, but it'll be an useful walkaround to configure delay (in milliseconds) before triggering reload.
And for the default value, I think 1~2s will be ok in general dev env.
I've made a PR #87 to add custom serializers for absinthe_plug
, and I've also set up a repo idi-ot/absinthe_test to try it out with msgpax
, but the query
curl -XPOST \
-H "Content-Type:application/graphql" \
-d "{posts {id}}" http://localhost:4000/api
fails with
[info] POST /api
[debug] ABSINTHE schema=nil variables=%{}
---
{posts {id}}
---
[info] Sent 200 in 1ms
[info] Sent 500 in 48ms
[error] #PID<0.432.0> running AbsintheTest.Web.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /api
** (exit) an exception was raised:
** (UnicodeConversionError) invalid encoding starting at <<220, 0, 100>>
(elixir) lib/list.ex:727: List.to_string/1
(phoenix_live_reload) lib/phoenix_live_reload/live_reloader.ex:94: anonymous fn/2 in Phoenix.LiveReloader.before_send_inject_reloader/2
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
(plug) lib/plug/conn.ex:971: Plug.Conn.run_before_send/2
(plug) lib/plug/conn.ex:392: Plug.Conn.send_resp/1
(phoenix) lib/phoenix/router/route.ex:161: Phoenix.Router.Route.forward/4
(phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
(absinthe_test) lib/absinthe_test/web/endpoint.ex:1: AbsintheTest.Web.Endpoint.plug_builder_call/2
(absinthe_test) lib/plug/debugger.ex:123: AbsintheTest.Web.Endpoint."call (overridable 3)"/2
(absinthe_test) lib/absinthe_test/web/endpoint.ex:1: AbsintheTest.Web.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) /Users/asd/Developer/elixir/absinthe_test/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
on the phoenix's side.
There is some more discussion on elixirforum
Hi!
I've created a phoenix project mounted on vagrant, everything works fine except the live reload.
Is there any place where i can find info about this issue? (live reload works only if i change files inside of the VM).
Thanks!
A couple of minutes ago, there was a bug report in the visualixir repository because of an errormessage which the user assumed to be from visualixir. The issue in question is koudelka/visualixir#13.
I think it would be easier for new users, if PLR were only emitting a warning instead of an error, and also give a short description (or at least link to one) of what went wrong and how to fix it.
I can see arguments though which do say it is an error, since the abscense of a backend renders PLR not working. Even though from a users perspective everything else does work, but filechanges take a moment to catch up.
So if keeping error, please add at least the description mentioned above and a small snippet that the application that everything else should work as expected.
Hi, I came cross a issue that the Phoenix Application
will close the connection after about 60s.
I have a nginx server
before the Application
, I found the nginx error log
show upstream prematurely closed connection while reading response header from upstream
.
Check the Application log
, I found the Application
just close the request without any log!
I think someone can find the behavior just use :timer.sleep(70_000)
in any handler.
I think the endpoint is responsible for this. So I check the endpoint and find the :http - the configuration for the HTTP server. Currently uses Cowboy and accepts all options as defined by Plug.Cowboy. Defaults to false
.
I found I should config the cowboy
, the cowboy server has some params, I think the idle_timeout
or 'inactivity_timeout` is more important for this issue.
So I config the http: [protocol_options: [idle_timeout: 300_000, inactivity_timeout: 300_000]],
and solve this problem.
My question is why the server not emit the error message ? I think it is hard to add the missing config if we do not have any obviously information.
An asset change is being triggered when the file mtime changes with no change in content. This can cause unexpected page reloads. To reproduce,
iex(2)> :crypto.hash(:md5, File.read!("priv/static/css/app.css")) |> Base.encode16
"1C16A9E2D001DDFF3292FC7C4EE9F89E"
iex(3)> File.touch("priv/static/css/app.css")
:ok
[debug] Live reload: priv/static/css/app.css
[debug] Live reload: priv/static/css/app.css
iex(5)> :crypto.hash(:md5, File.read!("priv/static/css/app.css")) |> Base.encode16
"1C16A9E2D001DDFF3292FC7C4EE9F89E"
This became an issue for me when I was replacing Brunch with Webpack. In my case, I configured Webpack to generate separate css and js. Each time Webpack runs, all of the css and js files are regenerated (even if there's no content change) which causes file mtime changes. So, if all I was doing was changing some css I would get a full page reload in my phoenix app since changes were detected in the js files.
I suspect most Webpack users will opt to use webpack-dev-server
for HMR. I have already made that change. However, this could present an integration issue with other build tools depending on how they work. For Brunch, it doesn't seem to be an issue because it doesn't touch the js files when the css files are built.
I tried to setup a dev environment where you could start everything what you need in separate docker containers. And found an interesting behaviour of the live reload package, because it did't recognized file changes when I did the changes on the host. On the other hand, when I changed some file directly inside the container it picked up the changes and reloaded the page.
But the most strange behaviour showed up, when I then (after the live roload, which was triggered by the change inside the container) changed the file again on the host. It reloaded. I did it again and it reloaded again, but after some seconds, it was the initial state again, when the changes on the host are not triggering this feature at all.
For a quick step in, here is a repo where someone could try it
https://github.com/dropfen/phoenix_live_reload_docker_bug
OR
git clone https://github.com/dropfen/phoenix_live_reload_docker_bug && \
cd phoenix_live_reload_docker_bug && \
docker-composer up
Since latest changes live reloading is not working in Windows 10.
Phoenix 1.2 worked.
Phoenix 1.3 doesn't.
Tested by two different users.
I was asked to post here instead of Phoenix tracker.
I don't know how to dig further the issue.
Erlang/OTP 20 [erts-9.0] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10]
Elixir 1.5.1
I have an app which has an iframe that comes from the same app. When I change CSS of iframe's site, then nothing happens, CSS in iframe is not reloaded.
Changes in HTML/JS of iframe's site works fine, the whole page is always reloaded. It's obvious because it always reloads page regardless of which file was modified. So the problem is with that complex CSS reloading.
Anyway, it would be nice to have option to force page refresh when CSS is changed. What if JS reads something from CSS on init and then CSS is reloaded without JS reloading?
Had this code in an EEX file:
<%= if @account[:local] %><% else %><% end %>
And when I hit save it caused the output terminal to fill with:
warning: unexpected beginning of EEx tag "<%" on "<% else %>", please remove "" accordingly
lib/my_server/templates/account/index.html.eex:25
It was filling so fast that the BEAM itself stopped responding to network input and nothing was working until I eventually had to kill
it (not even Ctrl+C or any other escape commands were working).
Notice that the do
was missing/forgotten off the if
, once that was added back in then the system worked fine. It should probably have some kind of throttle on it, or display an error message or something. This only seemed to happen via the live reloader, not normal compilation, hence why posting it here instead of elixir-lang for EEX.
This is on RedHat7 over SSH with Elixir 1.5.1 and OTP 20.
FileSystem allows to use custom backend. So instead of default ":fs_notify" (inotify-tools) I wish to use :fs_poll which doesn't need extra dependencies.
"start_link" has hard coded opts so there is no way to pass "backend: :fs_poll".
It would be good to alter this setting from "config.exs" or even "dev.exs" in Phoenix app.
When I start the server in debug mode (I use VSCode with the Elixir plugin) or start the debugger in an iex sesstion, and change an .eex file, I get the following error:
== Compilation error in file lib/simpleApp_web/views/page_view.ex ==
** (CompileError) lib/simpleApp_web/views/page_view.ex:2: module SimpleAppWeb is not loaded and could not be found
(elixir) expanding macro: Kernel.use/2
lib/simpleApp_web/views/page_view.ex:2: SimpleAppWeb.PageView (module)
(elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
I just created a new phoenix app using mix.
Starting without the debugger works fine.
Environment:
Windows 10
Erlang/OTP 20 [erts-9.2] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:10]
Elixir 1.7.2 (compiled with Erlang/OTP 19)
cowboy 1.1.2
cowlib 1.0.2
file_system 0.2.6
gettext 0.15.0
linguist 0.1.5
mime 1.3.0
phoenix 1.3.4
phoenix_html 2.12.0
phoenix_live_reload 1.1.5
phoenix_pubsub 1.1.0
plug 1.6.2
ranch 1.3.2
poison 3.1.0
How can I fix the problem?
Steps to reproduce:
mix phoenix.server
Result: a web page is reloaded indefinitely.
Expected result: a web page is reloaded once
I don't always see the behavior but I see it most of the time. The reason seems to be that template editing triggers the rebuild of files like _build\dev\lib\<projectname>\priv\static\js
which match happily against the default regexp priv/static/.*(js|css|png|jpeg|jpg|gif)$
which cause rebuild again.
As a result something as crude as setting live_reload
config to
patterns: [
~r{^.*(?!.*_build.*).*priv/static/.*(js|css|png|jpeg|jpg|gif)$},
~r{^.*(?!.*_build.*).*web/views/.*(ex)$},
~r{^.*(?!.*_build.*).*web/templates/.*(eex)$}
]
works. But that doesn't seem to be needed on other patforms. Why?
Live reload is designed for dev purpose so we should allow any kind of origin url.
Live reload/hot code reload on Gettext's *.po files does not work when build_path
in mix.exs
is set to ../../_build
(as it would be in an umbrella project). It works when changing templates etc.
When I remove build_path
from mix.exs
or simply change it to _build
, live reload starts working properly again.
Repo for example:
https://github.com/oskarkook/phoenix-gettext-reload-issue
/cc @chrismccord
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.