# Content aware debounce

**URL:** <https://discourse.nodered.org/t/content-aware-debounce/70933>\
**Category:** General\
**Tags:** function-node\
**Created:** [20 November 2022 17:32 UTC](https://discourse.nodered.org/t/content-aware-debounce/70933 "2022-11-20T17:32:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsl400](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dsl400/32/11876_2.png) [@dsl400](https://discourse.nodered.org/u/dsl400)\
**Post date:** [20 November 2022 17:32 UTC](https://discourse.nodered.org/t/content-aware-debounce/70933/1 "2022-11-20T17:32:28Z")

</div>

Any suggestion on how to debounce based on payload value?

messages are coming in via http request from multiple clients to the same endpoint  
`node-red/getInfo?client=<client-id>`  
some clients mite access the url multiple times per minute  
the goal is to send a single message per minute per client-id

using a simple debounce is not a good ideea because it could lead to data loss when multiple clients mke their requests at the same time

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 November 2022 17:53 UTC](https://discourse.nodered.org/t/content-aware-debounce/70933/2 "2022-11-20T17:53:08Z")

</div>

If I understand what you want correctly then the Delay node in Rate Limit, For Each msg.topic should do it.

---

<div class="post-metadata">

**Author:** ![dsl400](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dsl400/32/11876_2.png) [@dsl400](https://discourse.nodered.org/u/dsl400)\
**Post date:** [20 November 2022 18:34 UTC](https://discourse.nodered.org/t/content-aware-debounce/70933/3 "2022-11-20T18:34:35Z")

</div>

```auto
const ctxTo = context.get(clientId);
clearTimeout(ctxTo);

const to = setTimeout(() => {
    node.send({
        payload: clientId,
    });
}, 1000)

context.set(clientId, to);

```

I think this should do it

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 December 2022 18:35 UTC](https://discourse.nodered.org/t/content-aware-debounce/70933/4 "2022-12-04T18:35:09Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
