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

firestore-send-email sets document state to PROCESSING indefinitely #574

Closed
bdiz opened this issue Jan 23, 2021 · 9 comments · Fixed by #582
Closed

firestore-send-email sets document state to PROCESSING indefinitely #574

bdiz opened this issue Jan 23, 2021 · 9 comments · Fixed by #582
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@bdiz
Copy link

bdiz commented Jan 23, 2021

[REQUIRED] Step 2: Describe your configuration

  • Extension name: firestore-send-email
  • Extension version: v0.1.7
  • Configuration values (redact info where appropriate):
    • Cloud Functions location: us-central1
    • SMTP connection URI: smtp://<POSTMARK_API_TOKEN>:<POSTMARK_API_TOKEN>@smtp.postmarkapp.com:25
    • Email documents collection: emails
    • Default FROM address: User user@example.com
    • Default REPLY-TO address (Optional): Parameter not set
    • Users collection (Optional): users
    • Templates collection (Optional): emailTemplates

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

When adding a document to my emails collection, I am getting an indefinite state of PROCESSING.

Expected result

Expected the state to move beyond PROCESSING and send the mail.

Actual result

The document persists in the following state indefinitely.

createdAt: January 23, 2021 at 8:59:40 AM UTC-6
delivery:
  attempts: 0
  error: null
  leaseExpireTime: January 23, 2021 at 9:00:45 AM UTC-6
  startTime: January 23, 2021 at 8:59:44 AM UTC-6
  state: "PROCESSING"
from: "Ben Example <user@example.com>"
message:
  subject: "Example subject"
  text: "Example message"
private: true
replyTo: "ben.example@gmail.com"
toUids:
  0: "HkKeaL2MxJZkymy3g89OIBDDaYH3"
userId: "HkKeaL2MxJZkymy3g89OIBDDaYH3"

Details:

I am using Postmark. My smtp URI looks like smtp://<POSTMARK_API_TOKEN>:<POSTMARK_API_TOKEN>@smtp.postmarkapp.com:25. Postmark uses an API key with only hex characters and dashes so special characters doesn't seem like it would be the issue. The username and password for postmark are the same, the API token.

Debug:

I tried this smtp URI with nodemailer in a node repl locally and I was able to send an email successfully so it doesn't seem to be the Postmark smtp URI.

I also dug into the extensions code a little bit. In the extension, upon the create of the initial document, the cloud function updates attempts to 0 and state to PENDING. But what I see when observing the document in the firebase console is attempts are 0 and state is PROCESSING.

Looking at the switch statement for PENDING, it sets state to PROCESSING and then should call deliver().

case "PENDING":
case "RETRY":
// Wrapping in transaction to allow for automatic retries (#48)
await admin.firestore().runTransaction((transaction) => {
transaction.update(change.after.ref, {
"delivery.state": "PROCESSING",
"delivery.leaseExpireTime": admin.firestore.Timestamp.fromMillis(
Date.now() + 60000
),
});
return Promise.resolve();
});
return deliver(payload, change.after.ref);

However, if deliver() was called at all, why would attempts remain 0? My logs confirm that the "Attempting delivery..." message is not present either.

Is there something with await admin.firestore().runTransaction where it might be hanging there (though update of state to PROCESSING goes through)? I see there is a comment in the code about issue #48. Not sure if the issues there are still causing issues with this firebase extension.

@dackers86 dackers86 added the needs: author feedback Pending additional information from the author label Jan 25, 2021
@dackers86
Copy link
Member

Hi @bdiz

Can you confirm there are no errors in your logs for the extensions?

Additionally, I noticed that your protocol is smtp, does this work with smtps?

@bdiz
Copy link
Author

bdiz commented Jan 25, 2021

Hi @dackers86

No function errors (just infos and debug messages), but the last two messages are noteworthy. Providing all messages for your reference.

image
image

Using smtps instead of smtp the result is identical so far as I can tell by comparing the function logs and contents of the email document (ie. state is also PROCESSING).

@russellwheatley
Copy link
Member

Hey @bdiz, have you tried port 587 yet? That is the typical port for smtp protocol from email client to email server.

@bdiz
Copy link
Author

bdiz commented Jan 26, 2021

Hi @russellwheatley , with smtp and 587 it finished with SUCCESS and I received the email. Thank you.

I'll notify Postmark support of this issue, as they believe port 25 should work.

Also, as I mentioned previously it does work on port 25 when sent via nodemailer in a node REPL. I'm wondering if there is an enhancement that could get it working in this extension, and at a minimum provide better debug messages vs timing out in the PROCESSING state.

Thank you for looking this over and providing these suggestions.

@briankerr
Copy link

Hello, chiming in from Postmark's support perspective 👋

We offer ports 25 , 2525, and 587 for outbound SMTP. This could suggest that Firebase started blocking port 25. Blocking that port is pretty common as an anti-abuse measure for a host.

I couldn't find a blocked port list in Firebase's docs, but I see that Google Computer Engine blocks port 25 so it wouldn't surprise me if they started to use a similar rule here.

@russellwheatley
Copy link
Member

Thanks for the feedback, folks. Glad it worked @bdiz. What @briankerr said sounds correct to me. The Firebase cloud functions are using Google Cloud Platform so it is safe to assume that port 25 is simply being blocked.

@bdiz
Copy link
Author

bdiz commented Jan 27, 2021 via email

@russellwheatley
Copy link
Member

That makes sense to me. We should probably update the docs to inform users.

@russellwheatley russellwheatley added documentation Improvements or additions to documentation and removed needs: author feedback Pending additional information from the author labels Jan 27, 2021
@russellwheatley russellwheatley added this to Under consideration in Extension Update Tracker via automation Jan 27, 2021
@russellwheatley russellwheatley moved this from Under consideration to Accepted in Extension Update Tracker Jan 27, 2021
@dackers86
Copy link
Member

Initial PR added at #582

@russellwheatley russellwheatley moved this from Accepted to In review in Extension Update Tracker Feb 2, 2021
@russellwheatley russellwheatley moved this from In review to Launch approval pending in Extension Update Tracker Feb 2, 2021
@i14h i14h added this to the Feb-21-1 milestone Feb 8, 2021
Extension Update Tracker automation moved this from Launch approval pending to Closed Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Development

Successfully merging a pull request may close this issue.

5 participants