Skip to content

🐛 Bug Report:🐛 Bug Report: am getting an error on a cloud function, Internal curl errors has occurred within the executor! Error Number: 52. Error Msg: Empty reply from server\nError Code: 500 #9240

Closed as not planned

Description

@justinelut

👟 Reproduction steps

create a function, and deploy it to your appwriting hosting and execute it with bun, am using appwrite selfhosted, export

async function sendEmail(options) {
  try {
    // Validate scheduledAt date
    const scheduledAt = formatScheduledTime(
      options.scheduledAt,
      options.delayInMs
    );

    if (scheduledAt && new Date(scheduledAt) <= new Date()) {
      throw new Error('Scheduled time must be in the future.');
    }

    const payload = {
      messageId: options.messageId || generateUniqueId(),
      subject: options.subject,
      content: options.content,
      topics: options.topics || [],
      users: options.users || [],
      targets: options.targets || [],
      cc: options.cc || [],
      bcc: options.bcc || [],
      attachments: options.attachments || [],
      draft: options.draft || false,
      html: options.html ?? true,
      scheduledAt,
    };

    console.log(payload)

    const response = await axios.post(
      `${process.env.APPWRITE_FUNCTION_API_ENDPOINT}/messaging/messages/email`,
      payload,
      {
        headers: {
          'Content-Type': 'application/json',
          'X-Appwrite-Project': process.env.APPWRITE_FUNCTION_PROJECT_ID,
          'X-Appwrite-Key': process.env.APPWRITE_API_KEY,
        },
      }
    );

    console.log('Email sent successfully:')
    throw new Error ("error")
  } catch (error) {
    console.log("An error occured")
    throw new Error("error")
  }
}

// Utility to generate a unique ID
function generateUniqueId() {
  return (
    Math.random().toString(36).substring(2, 15) +
    Math.random().toString(36).substring(2, 15)
  ).substring(0, 36); // Ensures max length of 36 chars
}

this is the code am calling to send the emails.

await sendEmail({
      messageId: ID.unique(),
      subject: '🎉 Welcome to Fundi Wangu - Your Home Service Solution!',
      content: "hello",
      users: [userId],
      html: true,
    });

    return res.json({ success: true });
  } catch (error) {
   
    return res.json(
      {
        success: false,
        error: error.message,
      },
      500
    );
  }

i keep on getting this error on the cloud functions online

Internal curl errors has occurred within the executor! Error Number: 52. Error Msg: Empty reply from server\nError Code: 500

but the email is sent perfectly, here is my appwrite config

{
      "$id": "678abf890034afd234d2",
      "name": "sendemails",
      "runtime": "bun-1.0",
      "execute": ["any", "guests"],
      "events": ["databases.*.collections.*.documents.*.update"],
      "scopes": ["users.read", "messages.write"],
      "schedule": "",
      "timeout": 500,
      "enabled": true,
      "logging": true,
      "entrypoint": "src/main.ts",
      "commands": "bun install",
      "path": "functions/sendemails"
    }

👍 Expected behavior

The error should not be there since am returning json data and the function is sendin the email

👎 Actual Behavior

The function sends the email , but in the appwrite dashboard it shows error, Internal curl errors has occurred within the executor! Error Number: 52. Error Msg: Empty reply from server\nError Code: 500 and a failed status

🎲 Appwrite version

Version 1.6.x

💻 Operating system

Linux

🧱 Your Environment

No response

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

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Activity

  1. added
    bug
    on Jan 18, 2025
  2. changed the title [-]🐛 Bug Report:[/-] [+]🐛 Bug Report:🐛 Bug Report: am getting an error on a cloud function, Internal curl errors has occurred within the executor! Error Number: 52. Error Msg: Empty reply from server\nError Code: 500[/+] on Jan 18, 2025
  3. DH-555 commented on Jan 22, 2025

    @DH-555
    Contributor

    What's the environment of this?
    Self hosting? If so, what version and machine specs?

  4. added
    question
    product / functions
    on Jan 22, 2025
  5. github-actions commented on Feb 1, 2025

    @github-actions

    This issue has been labeled as a 'question', indicating that it requires additional information from the requestor. It has been inactive for 7 days. If no further activity occurs, this issue will be closed in 14 days.

  6. github-actions commented on Feb 15, 2025

    @github-actions

    This issue has been closed due to inactivity. If you still require assistance, please provide the requested information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugproduct / functionsquestionstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions