KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.75k stars 457 forks source link

"view_email" event fires twice #778

Closed kaeevans closed 7 months ago

kaeevans commented 7 months ago

Issue: "view_email" fires twice when I open an email from the inbox. I am using the boilerplate code from the gmailjs-node-boilerplate repo.

Solution tried: I followed the debugging instructions in issue 526 and confirmed that the "view_email" event-handler is only registered once. The call stack is the same each time "view_email" fires:

IMG_7012

Have you seen this before? Do you know what might be causing it?

josteink commented 7 months ago

This kind of seems to be a duplicate of https://github.com/KartikTalwar/gmail.js/issues/765.

The email_view and thread_view events has always been ... not extremely deterministic, due to how Gmail does rendering, pre-rendering etc. And new gmail has made things even more "interesting".

There's no "proper" fix for this yet, and the simplest way to deal with this is simply making your event-handling code idempotent (i.e. triggering the same event multiple times results in the same outcome as triggering it once), as suggested in the linked thread.

Closing this issue, as duplicate.