aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.97k stars 556 forks source link

Property 'ReadableStream' doesn't exist from SESClient #6013

Closed NorseGaud closed 2 months ago

NorseGaud commented 2 months ago

Checkboxes for prior research

Describe the bug

import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
import {AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY} from "@env"
import 'react-native-get-random-values'; // do not remove this line

export const sendEmail = async (userId) => {
    const sesClient = new SESClient({
        region: "us-west-2",
        credentials: {
            accessKeyId: AWS_ACCESS_KEY_ID,
            secretAccessKey: AWS_SECRET_ACCESS_KEY,
        }
    });
    const createSendEmailCommand = (toAddress, fromAddress) => {
        return new SendEmailCommand({
          Destination: {
            CcAddresses: [],
            ToAddresses: [toAddress],
          },
          Message: {
            Body: {
              Html: {
                Charset: "UTF-8",
                Data: "HTML_FORMAT_BODY",
              },
              Text: {
                Charset: "UTF-8",
                Data: "TEXT_FORMAT_BODY",
              },
            },
            Subject: {
              Charset: "UTF-8",
              Data: "EMAIL_SUBJECT",
            },
          },
          Source: fromAddress,
          ReplyToAddresses: [],
        });
    };
    const sendEmailCommand = createSendEmailCommand(
        "XXXXXXXXXX",
        "info@XXXXXXX,
    );

    try {
        await sesClient.send(sendEmailCommand);
    } catch (e) {
        console.error("Error stack:", e.stack);
    }
}
 ERROR  Error stack: ReferenceError: Property 'ReadableStream' doesn't exist
    at isStreamingPayload (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:282352:88)
    at ?anon_0__loop3 (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:281584:134)
    at throw (native)
    at ?anon_0_ (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:281608:23)
    at throw (native)
    at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:27804:26)
    at _throw (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:27826:29)
    at tryCallOne (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/packages/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:34495:26)
    at _callTimer (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:34374:17)
    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:34419:17)
    at callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:34625:44)
    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:3349:48)
    at anonymous (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:3122:45)
    at __guard (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:3321:15)
    at flushedQueue (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:3121:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle//&platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=app.memlane:3115:33)
"dependencies": {
        "@aws-sdk/client-ses": "^3.556.0",

SDK version number

aws-sdk/client-ses 3.556.0

Which JavaScript Runtime is this issue in?

React Native

Details of the browser/Node.js/ReactNative version

❯ node -v v20.11.1 ❯ npx react-native -v 12.3.6

Reproduction Steps

See descrption

Observed Behavior

See description

Expected Behavior

It sends an email

Possible Solution

No response

Additional Information/Context

No response

NorseGaud commented 2 months ago

Even a problem with SESv2Client

NorseGaud commented 2 months ago

SESClient uses import { getRetryPlugin, resolveRetryConfig } from "@smithy/middleware-retry"; and I see a bunch of references to isStreamingPayload in there.

NorseGaud commented 2 months ago

Does the SDK even work with react-native apps?

NorseGaud commented 2 months ago

Found the solution: https://stackoverflow.com/a/77744609/1875932

github-actions[bot] commented 2 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.