rameshsharma

rameshsharma

I am using Task.async to move a task in background. It is working fine in my local.
But when the code is deployed to azure environment it is not working.
Is there anything specifically I need to mention to make it work in environment.
Please suggest. My code below:-
‘’’
a = Task.async(fn →
verify_customer(current_user, first_pension)
end)
Task.await(a)

‘’’

First 7 of 7 Posts Switch mode

rameshsharma

rameshsharma OP

Any suggestions, please.

Nicd

Nicd

We need more information, just “not working” doesn’t tell us what might be wrong. Is there a crash? Are ther error logs? How did you build and deploy the code to Azure?

Note that the example you provided doesn’t make much sense, as it’s nearly the same as just running verify_customer(current_user, first_pension) in the original process. What are you aiming to accomplish with this task?

GunnarPDX

GunnarPDX

Have you tried running it without Task.async/await in prod? It’s really hard to help without error logs, the issue could be caused by a number of things unrelated to Task.async such as missing .env variables.

rameshsharma

rameshsharma OP

Yes, looks like you are correct, though in my local it works fine but I am getting some exceptions in logs due to fallback controller. Not sure if that could be the cause of the failure in azure environment.
I am getting such error in logs:-

[error] #PID<0.3298.0> running MyFutureNowWeb.Endpoint (connection #PID<0.3297.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: POST /api_v2/pension/create
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyFutureNowWeb.FallbackController.call/2
        (my_future_now 4.0.0) lib/my_future_now_web/controllers/fallback_controller.ex:8: MyFutureNowWeb.FallbackController.call(%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{user_signed_in?: true}, before_send: [#Function<0.28762384/1 in Plug.CSRFProtection.call/2>, #Function<2.77894870/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.32542428/1 in Plug.Session.before_send/2>, #Function<0.66442134/1 in Plug.Telemetry.call/2>, #Function<0.92375621/1 in Phoenix.LiveReloader.before_send_inject_reloader/2>], body_params: %{"employee_pension" => %{"creation_journey_type" => "employer", "current_employment" => "false", "end_year" => "2010", "pension_provider_id" => "", "proposed_employer_name" => "ABC Limited", "proposed_policy_number" => "", "start_year" => "2007"}}, cookies: %{}, halted: false, host: "localhost", method: "POST", owner: #PID<0.3298.0>, params: %{"employee_pension" => %{"creation_journey_type" => "employer", "current_employment" => "false", "end_year" => "2010", "pension_provider_id" => "", "proposed_employer_name" => "ABC Limited", "proposed_policy_number" => "", "start_year" => "2007"}}, path_info: ["api_v2", "pension", "create"], path_params: %{}, port: 4000, private: %{MyFutureNowWeb.Router => {[], %{Bamboo.SentEmailViewerPlug => ["sent_emails"]}}, :phoenix_action => :create, :phoenix_controller => MyFutureNowWeb.APIV2.PensionController, :phoenix_endpoint => MyFutureNowWeb.Endpoint, :phoenix_flash => %{}, :phoenix_format => "json", :phoenix_layout => {MyFutureNowWeb.LayoutView, :app}, :phoenix_router => MyFutureNowWeb.Router, :phoenix_view => MyFutureNowWeb.APIV2.PensionView, :plug_session => %{}, :plug_session_fetch => :done, :plug_session_info => :ignore}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{}, req_headers: [{"accept", "*/*"}, {"accept-encoding", "gzip, deflate, br"}, {"accept-language", "en-US,en;q=0.9"}, {"authorization", "Bearer SFMyNTY.g3QAAAACZAAEZGF0YW0AAAAkN2VhZjM1NmUtNTE0MS00ZTJiLTkwZDctMTRkNzgwYjViZTJlZAAGc2lnbmVkbgYADKLsbXQB.-yVqBqUSsRJtflbU-rit8j205c3Hb1fwnH8ysNhKlxs"}, {"cache-control", "no-cache"}, {"connection", "keep-alive"}, {"content-length", "321"}, {"content-type", "application/json"}, {"host", "localhost:4000"}, {"origin", "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop"}, {"postman-token", "d4922bac-7f43-4b65-2d7e-fb0bcc137c92"}, {"sec-fetch-dest", "empty"}, {"sec-fetch-mode", "cors"}, {"sec-fetch-site", "none"}, {"user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"}], request_path: "/api_v2/pension/create", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "FjLSWGVBjfYwu7kAAOxx"}], scheme: :http, script_name: [], secret_key_base: :..., state: :unset, status: nil}, {:ok, %MyFutureNow.Task{__meta__: #Ecto.Schema.Metadata<:loaded, "tasks">, admin_assignee: #Ecto.Association.NotLoaded<association :admin_assignee is not loaded>, admin_assignee_id: nil, admin_author: #Ecto.Association.NotLoaded<association :admin_author is not loaded>, admin_author_id: nil, body: nil, completed: false, completed_at: nil, completion_pension_status: "verify_customer_details", customer_pension: #Ecto.Association.NotLoaded<association :customer_pension is not loaded>, customer_pension_id: 844, due_date: ~D[2020-09-09], id: 457, inserted_at: ~N[2020-09-08 13:35:00.876097], priority: 1, snooze_count: 0, subject: "LexisNexis IDU FAIL, issue email to customer, set pensions to On Hold", updated_at: ~N[2020-09-08 13:35:00.876097], user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: 521, uuid: "7bb33496-6690-4780-955a-3852d0d49938"}})

kokolegorille

kokolegorille

Please note You are not using the right code fence to mark code… I updated your last post to show the difference. It should be ```

GunnarPDX

GunnarPDX

That error message is showing that your fallback controller cant match whats getting returned, which isn’t really the real error. Could you post the full function with async-await in it?

rameshsharma

rameshsharma OP

Issue is resolved…The problem was with the fallback controller. Thanks all.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
wintermeyer
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

We're in Beta

About us Mission Statement