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
Email sent but callback is failed #9
Comments
Please @endroca share the actual code of |
Thank you, I updated the post |
Currently looked into it. I feel this might be because you are not calling the So, for now please update the async handle(link, done) {
console.log(Job [${this.constructor.name}] - handler called: status=running; id=${this.id});
link.reportProgress(10);
let data = link.data; // arguments passed into the constructor
let error = null;
let result = null;
try {
result = await Mail.send(data.emailTemplate, data.emailBody, message => {
message.to(data.emailAddress);
message.from(data.emailFrom);
message.subject(data.emailSubject);
});
link.reportProgress(50);
} catch (err) {
link.reportProgress(50);
error = err;
result = undefined
} finally {
link.reportProgress(100);
}
return done(error, result);
} And then, try again Let me know the outcome of this please @endroca . Thank you |
The error continues =(
I used the same function that you described async handle(link, done) {
console.log(
`Job [${this.constructor.name}] - handler called: status=running; id=${this.id}`
);
link.reportProgress(10);
const { data } = link; // arguments passed into the constructor
let error = null;
let result = null;
try {
result = await Mail.send(data.emailTemplate, data.emailBody, message => {
message.to(data.emailAddress);
message.from(data.emailFrom);
message.subject(data.emailSubject);
});
link.reportProgress(50);
} catch (err) {
link.reportProgress(50);
error = err;
result = undefined;
} finally {
link.reportProgress(100);
}
return done(error, result);
} The funny thing is that I get two emails, for the failure attempt |
@endroca Please can you update the handle function as below: async handle(link, done) {
console.log(
`Job [${this.constructor.name}] - handler called: status=running; id=${this.id}`
);
link.reportProgress(10);
const { data } = link; // arguments passed into the constructor
let error = null;
let result = null;
try {
result = await Mail.send(data.emailTemplate, data.emailBody, message => {
message.to(data.emailAddress);
message.from(data.emailFrom);
message.subject(data.emailSubject);
});
link.reportProgress(50);
} catch (err) {
link.reportProgress(50);
error = err;
result = undefined;
} finally {
link.reportProgress(100);
done(error, result);
}
} It should be fine now |
I understand that with asynchronous call sending email it really makes sense to place the return function within the finally } finally {
console.log('success');
link.reportProgress(100);
done(error, result);
}
However, the system returns the error function even before calling the "done" function |
@endroca confirming from the bee-queue repo. The handle function needs to return a Promise. Also from the reportProgress() function returns a promise as well and needs to be "awaited". See below: async handle(link) {
console.log(
`Job [${this.constructor.name}] - handler called: status=running; id=${this.id}`
);
await link.reportProgress(10);
const { data } = link; // arguments passed into the constructor
let error = null;
let result = null;
try {
result = await Mail.send(data.emailTemplate, data.emailBody, message => {
message.to(data.emailAddress);
message.from(data.emailFrom);
message.subject(data.emailSubject);
});
await link.reportProgress(50);
} catch (err) {
error = err;
result = undefined;
await link.reportProgress(50);
} finally {
await link.reportProgress(100);
return error === null ? Promise.resolve(result) : Promise.reject(error);
}
} |
@endroca have you tried the above ? any luck ? |
Hi @stitchng |
Any solution here, having the same problem. For now I have stopped it sending the email more than once by setting retryCount to '0' if you set to 0 default value of 2 replaces it (This in itself is an issue) |
A new version of the adonis-queue library has just been released - v0.1.10 on NPM. @endroca @afolabiabass @mavafaei @stitchng |
@endroca @afolabiabass can you give feedback on the latest release please ? Do the errors still persist ? |
@mavafaei @afolabiabass @endroca how is the new version for adonis-queue (v0.1.10) working ? Still having errors ? |
Package version
NPM 6.12.1
Node.js and npm version
v10.16.0
Adonis version
4.1
Sample Code (to reproduce the issue)
JOB
Event
Response
The email is sent successfully but the callback that is made is invalid
The text was updated successfully, but these errors were encountered: