eddy147
Once in a while I get a :noproc error:
** (stop) exited in: GenServer.call({:via, Registry, {:trip_generation_server, "804194805327673"}}, :send_to_processing, 5000)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
(elixir 1.14.2) lib/gen_server.ex:1027: GenServer.call/3
(vehicle_processing 0.1.0) lib/vehicle_processing/processor.ex:1243: VehicleProcessing.Processor.run_trip_generation_server/3
(stdlib 4.2) gen_server.erl:1161: :gen_server.try_terminate/3
(stdlib 4.2) gen_server.erl:1351: :gen_server.terminate/10
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: :check_end_of_processing
State: %VehicleProcessing.Processor.State{vehicle: nil, unique_identifier: "804194805327673", data_start_at: nil, data_stop_at: nil, last_active_at: ~U[2023-10-30 10:30:47.181818Z], parking_notification_sent: false, driver_id: %{ibutton: nil, log: nil, permission: nil}, gps_based_properties: %{distance: nil, speed: nil, time: nil}, sent_vehicle_start_trigger?: false, at_least_one_non_heartbeat_message?: true, messages: [], timer: #Reference<0.3285835207.3288072193.194993>, geofences: [], previous_trip_point: nil, gps_reference: nil, previous_state_of_charge: nil, notifications_sent: %{battery_level_low: nil, battery_range_low: nil, battery_state_of_charge_low: nil}, gps_send: 1}
I start the TripGenerationServer dynamically:
defp run_trip_generation_server(state, f, tries) do
if tries > 0 do
case Registry.lookup(:trip_generation_server, state.unique_identifier) do
[] ->
case TripGenerationServerSupervisor.start_child(state.unique_identifier) do
{:ok, _pid} ->
f.(state)
e ->
Logger.warning(
"Can not start TripGenerationServer #{state.unique_identifier}: #{inspect(e)}"
)
Process.sleep(200)
run_trip_generation_server(state, f, tries - 1)
end
[{_pid, _nil}] ->
f.(state)
end
else
Logger.error("Can not startTripGenerationServer #{state.unique_identifier}")
end
state
end
And I get the :noproc error when
[{_pid, _nil}] ->
f.(state)
defmodule VehicleProcessing.TripGenerationServerSupervisor do
@moduledoc false
use DynamicSupervisor
require Logger
alias VehicleProcessing.TripGenerationServer
def start_link(_) do
Logger.info("start #{__MODULE__}")
DynamicSupervisor.start_link(__MODULE__, [], name: __MODULE__)
end
def start_child(unique_identifier) do
child_spec = %{
id: TripGenerationServer,
start: {TripGenerationServer, :start, [unique_identifier]},
# the child process is restarted only if it terminates abnormally,
# i.e., with an exit reason other than :normal, :shutdown, or {:shutdown, term}
restart: :transient,
shutdown: :brutal_kill,
type: :worker,
modules: [TripGenerationServer]
}
DynamicSupervisor.start_child(__MODULE__, child_spec)
end
@impl true
def init([]) do
DynamicSupervisor.init(strategy: :one_for_one)
end
end
How is this possible?
It also happens sometimes in a test, and when I run the test again, the error does not appear; or it appears in another test, totally random.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
At least in test env it’s possible the process is exiting before the test completes?
eddy147
That also sometimes happens, but in this case I get {:ok, pid} but still the :noprocess error.
I did not show this in my question, but in my init/1 function of the TripGenerationServer a query to the DB was called:
should_send_to_processing?(imei)is a call to the DB.
I removed that, and not seen the error again in my tests.
So is it possible that we get {:ok, pid} back already before the init/1 function is complete?
dimitarvp
Oh, don’t do that. I am not sure that’s your problem but always do these with
handle_continue!Also a piece from
handle_calldocs:al2o3cr
One thought:
TripGenerationServerSupervisor.start_childwill return the child PID as soon as the process is started, but a call using aviatuple won’t succeed until the child process has registered (presumably using code inTripGenerationServer)The error you’re seeing could happen if the callback passed to
run_trip_generation_server“wins the race” and tries to make a call too early.