Warning: mtime was set to the future - triggered by two rapid successive calls to Elixir compiler (possible bug - need your help to test)

Although parts of the following describe behavior observed in Phoenix, this is not a Phoenix bug (I’ll explain why later). It appears to be an Elixir bug, so I’m posting this in the “Elixir” category.

The possible bug

Recently, I encountered the following warning while developing a Phoenix application:

warning: mtime (modified time) for "lib/demo_web/controllers/page_html.ex" was set to the future, resetting to now

Have any of you encountered this issue? I haven’t seen any similar reports in the community.

To reproduce it:

  1. Create an app: mix phx.new demo --no-ecto --no-live --no-tailwind
  2. Enter the dev environment: cd demo && iex -S mix phx.server
  3. Visit http://localhost:4000 in your browser and keep the tab open (this is necessary, as it triggers the edge case)
  4. Modify demo/lib/demo_web/controllers/page_html/home.html.heex and save
  5. The warning should appear in your IEx. If not, repeat step 4 a few more times.

The chain of logic leading to the warning:

  1. We modify demo/lib/demo_web/controllers/page_html/home.html.heex.
  2. Phoenix.LiveReloader detects the change and pushes an event to the browser.
  3. The browser requests / to refresh, triggering Phoenix.CodeReloader to reload the code.
  4. The refreshed page requests /phoenix/live_reload/socket to re-establish live reloading, triggering Phoenix.CodeReloader to reload the code again.

I suspect the warning is caused by two rapid successive calls to Phoenix.CodeReloader.reload/2, which in turn calls mix compile.elixir. To verify this, I created a minimal reproduction: GitHub - zekedou/elixir-compile-warning-1 · GitHub — and indeed, the warning reproduced.

I need help testing whether this is consistently reproducible across platforms and elixir versions. So far I’ve only tested on macOS — it would be great if those on Linux and Windows could test as well.

If this does turn out to be a bug, we’ll have already collected the necessary environment information.

How to help?

Run the project at GitHub - zekedou/elixir-compile-warning-1 · GitHub and report your results in the following format:

Reproduced?: Y/N
OS: <like macOS 15.7.5>
Erlang and Elixir:
<output of `elixir --version`>
2 Likes
Reproduced: Y
OS: Ubuntu 24.04.3 LTS
Erlang and Elixir:
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1] [jit:ns]

Elixir 1.19.5 (compiled with Erlang/OTP 28)
1 Like

Fixed in main as part of the issue you opened. They both had the same root cause. Please give main a try and let me know how it goes!

Thank you for all reports! Also please double check we haven’t reintroduced View modules are not recompiled after triggering compilation error of unmatched tag in template files. · Issue #6476 · phoenixframework/phoenix · GitHub. :heart:

3 Likes

All the issues have been checked again:

  • Elixir issue #15277 has been fixed.
  • Elixir issue (mentioned here) has been fixed.
  • Phoenix issue #6476 has been fixed.

Thanks! @josevalim @gtcode

1 Like