Skip to content

TypeError: (0, import_protocols.resolvedPath) is not a function error when using release build in android  #6656

@saifalitai

Description

@saifalitai

Checkboxes for prior research

Describe the bug

I am encountering an error when trying to use the @aws-sdk/client-s3 package within a React Native project. The error seems to occur due to a missing or incompatible function import_protocols.resolvedPath. This issue prevents me from successfully uploading files to S3 from my React Native application.

### Code Sample:

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import RNFS from "react-native-fs";

const uploadFileToS3 = async (filePath) => {
  const s3Keys = {
    region: "us-west-2",
    s3Bucket: "my-bucket",
    key: "YOUR_ACCESS_KEY",
    sKey: "YOUR_SECRET_KEY",
  };
  const s3Client = new S3Client({
    region: s3Keys.region,
    credentials: {
      accessKeyId: s3Keys.key,
      secretAccessKey: s3Keys.sKey,
    },
  });

  const content = await RNFS.readFile(filePath, 'ascii');
  const uploadParams = {
    Bucket: s3Keys.s3Bucket,
    Key: "path/to/file",
    Body: content,
    ContentType: "application/octet-stream",
  };

  try {
    const command = new PutObjectCommand(uploadParams);
    await s3Client.send(command);
  } catch (error) {
    console.error("Upload error:", error);
  }
};

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

React Native

Details of the browser/Node.js/ReactNative version

React Native version: 0.66.5 AWS SDK version: @aws-sdk/client-s3 (version: "3.688.0") Node version: v20.11.0 Platform: Android (34) react: "18.2.0",

Reproduction Steps

  1. Install @aws-sdk/client-s3 in a React Native project.
  2. Configure the S3 client and attempt to upload a file.
  3. Observe the TypeError related to import_protocols.resolvedPath.

Observed Behavior

Here is the exact error message:

TypeError: (0, import_protocols.resolvedPath) is not a function. (In '(0, import_protocols.resolvedPath)(path, _this2.input, memberName, labelValueProvider, uriLabel, isGreedyLabel)', '(0, import_protocols.resolvedPath)' is undefined) at line: 146395, column: 59, sourceURL: 'index.android.bundle'

Expected Behavior

The file should be successfully uploaded to S3 without throwing any errors.

Possible Solution

Updated @aws-sdk/client-s3 to the latest version.
Cleared npm cache and reset React Native bundler cache.
Tried alternative S3 libraries, but prefer to use @aws-sdk/client-s3.
Additional Context: This error appears specifically related to React Native, as similar code works fine in a Node.js environment.

Special not is working debug build on @aws-sdk/client-s3 (version: "3.609.0"). but not worked on release build

Additional Information/Context

Could you please provide guidance on resolving this or recommend a workaround? Thank you for your assistance!

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions