Skip to content

net::ERR_H2_OR_QUIC_REQUIRED error while uploading the data to S3 for package @aws-sdk/client-s3 from client side #6504

@blazedglimmer

Description

@blazedglimmer

Checkboxes for prior research

Describe the bug

uploadissue

Regression Issue

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

SDK version number

"@aws-sdk/client-s3": "^3.654.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.14.0

Reproduction Steps

Following is the code snippet for UPLOAD FILES in S3 Bucket from client side:

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

export const uploadFileToS3 = async (
  file: File,
  accessKey: string,
  secretKey: string,
  handleProgress: (progress: number) => void
): Promise<{ src: string }> => {
  const s3 = new S3Client({
    credentials: {
      accessKeyId: accessKey,
      secretAccessKey: secretKey,
    },
    region: process.env.BUCKET_REGION,
  });

  return new Promise(async (resolve, reject) => {
    try {
      const contentType = file.type;

      // Read the file as a stream
      const reader = file.stream().getReader();
      const fileStream = createProgressStream(file, handleProgress);

      // Create the S3 upload parameters
      const params = {
        Bucket: process.env.BUCKET_NAME, 
        Key: file.name,
        Body: new Response(fileStream).body, 
        ContentType: contentType,
        ACL: "public-read",
      };

      const command = new PutObjectCommand(params);

      // Send the command to S3
      await s3.send(command);

      resolve({
        src: `https://${params.Bucket}.s3.${s3.config.region}.amazonaws.com/${params.Key}`,
      });
    } catch (error) {
      reject(error);
    }
  });
};

// Helper function to track the progress
const createProgressStream = (
  file: File,
  handleProgress: (progress: number) => void
) => {
  const fileSize = file.size;
  let uploaded = 0;
  const reader = file.stream().getReader();
  return new ReadableStream({
    async start(controller) {
      handleProgress(0); // Initially 0%
    },
    async pull(controller) {
      const chunk = await reader.read();
      if (chunk.done) {
        controller.close();
        return;
      }

      uploaded += chunk.value.length;
      const progressPercentage = Math.round((uploaded / fileSize) * 100);
      handleProgress(progressPercentage);
      controller.enqueue(chunk.value);
    },
  });
};

Observed Behavior

When the s3 upload api is getting called, it is giving this error in its status in network tab status. I was implementing this with next js.
net::ERR_H2_OR_QUIC_REQUIRED

Expected Behavior

It should upload the file and return back the resolved url of S3.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions