Event Listeners execute twice for each event

Hi, I’m applying Event Listeners to my UXP application. I have followed the guide here and have these code in my app:

var listener = (e,d) => { console.log(e,d); }
require('photoshop').action.addNotificationListener([
    {
        event: "select"
    },
    {
        event: "open"
    } // any other events...
], listener);

This code is running, but there are 2 logs in console for each event. For e.g. when selecting a file I see this in the console:

select {_target: Array(1), documentID: 224, _isCommand: false}
select {_target: Array(1), documentID: 224, _isCommand: false}

Is this the expected behavior or do I have something wrong?

Thank you!

I experienced this a lot while developing a plugin. Restarting Photoshop usually helped. Really annoying. I just hope it’s a development related bug. Didn’t notice any issues when installed packaged CCX

2 Likes

Might be a good idea to add a console.log("adding listeners") or something to your code – that way you could see each time the code is registering for these listeners, which might be useful in tracking down when the issue arises.

I think UDT could contribute to this as plugins can sometimes be reloaded in quick succession after a change is detected. In that case, your users wouldn’t see it, since they don’t use UDT to load the plugin into Ps.

This happens even with Alchemist (loaded via UDT). When listening for events, sometimes it shows two of the same. Sometimes isCommand differs (true vs false). So I really doubt it’s a plugin issue

I had this yesterday and the only way I could clear it was to reset Photoshop Preferences

I had same experience during this past weekend also. Only difference between the duplicates was isCommand value

I believe it is somehow connected with Alchemist listener. In my case, this behavior reproduces only if Alchemist Listener is enabled.

maybe need restart UDT app

I have the same issue, every event is executed twice!