n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
42.49k stars 5.52k forks source link

Clockify Trigger Polling not working #3364

Open JustAmply opened 2 years ago

JustAmply commented 2 years ago

Describe the bug

The Clockify trigger is not being fired when the polling rates (Poll Times) of the trigger node are shorter than the tracked time-entry in Clockify. This means that the polling rate has to be higher than the length of the event if you want to use the Trigger node.

Clockify Trigger Poll Times

Here you can see the code containing the bug: https://github.com/n8n-io/n8n/blob/6dcdb30bf41443099f4abea54f9399f43e9de915/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts#L109-L110 The Clockify-API gets sent a request within a period of time between the last point in time the API was checked and now. The variable webhookData.lastTimeChecked is set to now right beneath this.

The problem of this approach is, that only time-entries within Clockify that have their start AND end time between webhookData.lastTimeChecked and now are being requested from the API. If I start and stop a timer after a few seconds, the trigger gets fired within a minute (if I have the polling rate set to the min value). But any timer that's longer than that doesn't get requested, because the API only returns entries that are completely within the time-range, not just partially.

Idea for an easy fix

A fix could be setting qs.start to the end of the last finished timer-entry of the workspace.

Workaround

In the meantime and if others are looking for a temporary solution, here's a (suboptimal) workaround: It depends on what you're doing, but if your automation is not time-sensitive, then you can set the polling rate to "Every Day" or even longer to expand the maximum length of Clockify-events that can trigger the node.

Here is a link to the forum where this issue was being discussed: https://community.n8n.io/t/polling-not-working-or-am-i-doing-something-wrong/10576/3

Joffcom commented 2 years ago

Hey @Justus502,

That is a nice find, I can see that @that-one-tom has added this to our internal bug tracker.

Joffcom commented 1 year ago

Just adding that internally we are tracking this as NODE-50

prionkor commented 3 weeks ago

I this being worked on?

Joffcom commented 1 week ago

Hey @prionkor,

It isn't at the moment as I want to fully change how the node works and instead of being polling based I want to make it use webhooks but I will see if I can get to this one soon as it has been opened for a while