Can't publish the same action twice
Hello, I have a challenge with notifications that I don't know how to solve. Would appreciate any advice!
When an interaction that is part of the session is updated, I want to sent notification to both the interaction and the session. The below doesn't work:
None of the notifications are sent. If I comment out the repeated lines, the notifications are sent as usual.
A hack would be to do something like
but that would send out 4 notifications to of them with wrong ids.
Any suggestions how I should approach this? Or maybe it's a feature request for Ash Notifications to support more complex templates and/or allow duplicate publish entries?
6 Replies
๐ค that should work
please open a bug report
Thanks Zach, will do. And yes, I expected this to work as it's natural complement to the powerful template syntax.
GitHub
Can't publish the same action twice ยท Issue #2150 ยท ash-project/ash
Versions ash 3.5.23 ash_admin 0.13.10 ash_authentication 4.9.4 ash_authentication_phoenix 2.10.1 ash_graphql 1.7.15 ash_phoenix 2.3.7 ash_postgres 2.6.8 ash_sql 0.2.82 Operating system MacOS Sequoi...
If you have a chance to provide a reproduction that would be excellent as well
like a project I can run etc.
Yes, working on this. I also asked Claude Code to investigate - will let you know if it finds anything interesting ๐
Hm, Claude Code thinks that it should work:
Working on a repro
Ok, so maybe it was a false alarm, although it's complicated.
I was running my test script
mix run my-script.exs
at the same time I was running mix -S iex phx.server
in another terminal window (to make tidewave MCP available for Claude). Turns out this somehow interfers with notifications:
1/ Without the second command running, I get all the notifications as expected.
2/ With the second command running, the notifications log output is printed to the iex phx.server
terminal window for other notifications, but the :process_response
is never triggered it seems - I don't see the log output for it in any of the windows.
It might be that somehow Endpoint broadcasting is not working - but the logs printed by setting config :ash, :pub_sub, debug?: true
should be printed before the Endpoint.broadcast is called, correct?
Any thoughts on how to test this further?
Ok, nevermind. I figured it out!
1/ I had two different Elixir processes running, they were not talking to each other
2/ The first process, mix run, used Oban to schedule some LLM jobs; once they were complete, they would call an update action on a resource
3/ That resource is backed by Ets (during testing), so it only existed in the memory of the mix run process
4/ It seems that the Oban job was picked up by the second process, mix -S iex phx.server, since Oban is backed by the same database that both processes had access to
5/ So once the Oban job was complete in the second process, it tried to find a Resource to update and failed (since that object doesn't exist in that process)
5/ A failed update action, therefore, was not triggering the notification
So all is good with Ash notifications - it was a complete unrelated issue. Sorry for the false alarm!No problem ๐
Put that write up in the issue and close it if you can, maybe it will help someone in a similar situation ๐