Closed timonson closed 2 years ago
Could you provide a reproduction and the logs when you set in the client options debug.log
to true see https://github.com/EC-Nordbund/denomailer#options
I tried but I can't because it works in a minimal reproduction like expected. Strangely it only happens when I make other http requests through the native http API before making a request which invokes smtp. In this case the send
method is stalling before the error occurs. There seems to be some kind of pile-up. If I don't do the other http requests (just normal static file requests), the error doesn't happen.
Only aaa
is logged when I make other http requests before:
console.log("aaa", sendConfig);
await smtpClient.send(sendConfig);
console.log("bbb");
await smtpClient.close();
console.log("ccc");
http-requests = fetch or what?
Automatic browser requests, originiating from an html file. I have a form which invokes smtp on submit. If I don't refresh the site before submitting (because I already visited the page before the server restart), everything works as expected. But when I refresh the site and then submit, the send
method is stalling on the server side.
The mentioned BadResource Error seems to happen on a subsequent send
call.
Oh... so you have also a http-server running in deno...
Yes
Oh... so you have also a http-server running in deno...
Edited previous post
Are you sure the connection is not closed? If you call close and then send an EMail I would expect that or a similar error.
Yes you are right, that's it and it is working now. I actually closed it intentionally. I must have misunderstood the code in denomailer/client/mod.ts
because I thought that the internal client would reconnect automatically. Really sorry for wasting our time.
Thanks a lot!
With this
import { SMTPClient } from "https://deno.land/x/denomailer@1.0.0/mod.ts";
const client = new SMTPClient({
debug: {
log: true,
},
connection: {
hostname: "smtp.gmail.com",
auth: {
username: "xxx",
password: "xxx",
},
},
});
await sleep(2000);
await client.close();
await client.send({
from: "xxx",
to: "xxx",
subject: "TEST",
content: "ABC",
});
function sleep(to: number) {
return new Promise<void>((res) => setTimeout(res, to));
}
I get the same error so I think your connection got closed!
Never mind I fould a small bug while debuging this :D (not related)
Describe the bug
The following error is thrown and it can't be caught:
OS: Arch deno version: