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

🐛 Bug Report: email step in queued when generating email attachment for 6 seconds #6834

Open
2 tasks done
yunluo1024 opened this issue Nov 4, 2024 · 2 comments
Open
2 tasks done
Labels

Comments

@yunluo1024
Copy link

📜 Description

using sendgrid provider to send email with attachments, when rendering a large attachment for around 6 seconds, the email can't be sent and stuck.

👟 Reproduction steps

In sendgrid provider, when rending a large attachment, the time spent for rendering is around 6 seconds; Novu can't send the email and stuck in email step.

export const myWorkflow = workflow(
 'WorkflowName', 
  async ({ step, payload, subscriber }) => {
    await step.email(
      'send-email',
      async () => {
        const content = ListingOrderQcAcceptedEmailSeller(
          payload.emailData.content,
        );

        return {
          subject: payload.emailData.subject,
          body: render(content),
        };
      },
      {
        providers: {
          sendgrid: async () => {
          
            console.time('process');
            const pdfContent = await convertHtml2Pdf(
              render(
                TaxInvoiceProducePlusFreight(
                  payload.emailData.attachmentList[0].content,
                ),
              ),
            );
            console.timeLog('process');
            console.timeEnd('process');
            const attachments = [];
            attachments.push(
              getAttachment({
                fileName: payload.emailData.attachmentList[0].fileName,
                content: pdfContent,
              }),
            );

            // @ts-ignore
            return {
              attachments,
            };
          },
        },
      },
    ),
  },
  {
    payloadSchema,
  },
);

👍 Expected behavior

It should send email with attachment.

👎 Actual Behavior with Screenshots

stuck in email sending.
Screenshot 2024-11-04 at 11 01 38 AM

Novu version

Novu SAAS

npm version

No response

node version

No response

📃 Provide any additional context for the Bug.

it actually did not send the email with attachments.

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

@github-actions github-actions bot added the triage label Nov 4, 2024
@kasyap1234
Copy link

kasyap1234 commented Nov 5, 2024

@yunluo1024 did you try to render the attachment asynchronously ?
Offload the attachment generation to a separate, asynchronous process. You can save the generated attachment to a storage location (like S3) and then retrieve it when it is ready.
I feel in this way , you wont face this issue , because rendering is taking time ,so why not offload it .

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

No branches or pull requests

2 participants