Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(worker): delay duration #7496

Open
wants to merge 12 commits into
base: next
Choose a base branch
from

Conversation

djabarovgeorge
Copy link
Contributor

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 3e57134
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/6786ff9ec9b9e90008f25661
😎 Deploy Preview https://deploy-preview-7496.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 3e57134
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/6786ff9eaf17c10008d54fa3
😎 Deploy Preview https://deploy-preview-7496.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

…duration-limits-for-digest-and-delay-steps-in-code-first
* If queueNextJob.execute returns undefined, we stop the workflow.
* Otherwise, we continue trying to queue the next job in the chain.
*/
private async tryQueueNextJobs(job: JobEntity): Promise<void> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was needed because not we have a possible exception on finally block which is not handled.

for the following workflow SMS => DELAY => IN-APP
the problem is the we handle the delay step (calculate the duration) while we executing the SMS job.
a better solution would be to handle the DELAY step while we execute the DELAY job.
a refactor will take a lot of time and we will need to create backward compatibility support for old jobs as well.

const cronExpression = parseCronExpression(command.cron);
const firstTime = cronExpression.next().toDate();
const secondTime = cronExpression.next().toDate();
private isCronDeltaDeferDurationExceededTier(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to create a simple "smart solution" however on every approach it became very complicated very fast, therefore I created a more simple solution where we validate the next 50 iterations of the crown with an exit if we pass 2 years.

@@ -142,6 +166,10 @@ const isCronExpression = (cron: string) => {
};

const isRegularDeferAction = (command: TierRestrictionsValidateCommand) => {
if (command.deferDurationMs) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bug we had, where we did not check the deferDurationMs that the worker was passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant