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

Stop processing next hooks #330

Open
vivekpatel5996 opened this issue May 3, 2023 · 5 comments
Open

Stop processing next hooks #330

vivekpatel5996 opened this issue May 3, 2023 · 5 comments

Comments

@vivekpatel5996
Copy link

vivekpatel5996 commented May 3, 2023

Hello,

I am throwing an error from the sender:connection hook, even though next hooks are called and mail is delivered.

I have some condition that checks if DKIM is not available then throw the error and not proceed further hooks and drop the message but still it's processing and printing console from sender:delivered hook.

app.addHook('sender:connection', async (delivery, options, next) => { throw new Error("No DKIM available") }

app.addHook('sender:delivered', async (delivery, info, next) => { console.log("Delivered") }

Anyone can help on how to throw the error and not processing further hooks ?

And is there any proper way to drop the message from the queue and not process that particular message ?

created issue #329 (comment) but not resolved by the solution.

Thanks.

@louis-lau
Copy link
Contributor

This is a free open source project. A tag and reminder after only 8 hours of the issue being opened isn't helpful, things like this can lead to stress for open source maintainers. I know this is probably not your intention at all! But I thought I would just mention it. :)

Andris and others are already watching this repository and will receive notifications without an extra mention.

@roshanjonah
Copy link

Sorry about that. My apologies. That was not my intention. Won't happen again :)

@roshanjonah
Copy link

roshanjonah commented Jul 13, 2023

@andris9 It would be great if you could please look into this.

@dazoot
Copy link
Contributor

dazoot commented Sep 13, 2023

I think @andris9 made it very clear that you need to throw an app.reject exception.

throw app.reject(envelope, 'reject', messageInfo, 'No DKIM available')

By just throwing a random Error, the plugin will be marked as failed but other plugins / hooks will continue to run.
Also make sure that the 2 hooks you have pasted are from the same plugin, otherwise, the one with console.log will keep running.

I see no issue here. Should have this closed.

@rjnz2023
Copy link
Contributor

rjnz2023 commented Jul 5, 2024

@dazoot @andris9 This seems to work only with message:queue hooks and not the sender:connection which is what we are using. So how do we handle that? Any ideas?

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

No branches or pull requests

5 participants