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

Error: The 'cache' field on 'RequestInitializerDict' is not implemented. #6493

Closed
3 of 4 tasks
2820402 opened this issue Sep 19, 2024 · 3 comments
Closed
3 of 4 tasks
Labels
bug This issue is a bug.

Comments

@2820402
Copy link

2820402 commented Sep 19, 2024

Checkboxes for prior research

Describe the bug

export const r2 = (c: RequestT) => {
    const { R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY } = env<ENV>(
        c,
        'workerd'
    );

    return new S3Client({
        region: 'auto',
        endpoint: R2_ENDPOINT,
        credentials: {
            accessKeyId: R2_ACCESS_KEY_ID,
            secretAccessKey: R2_SECRET_ACCESS_KEY,
        },
    });
};

when I create CreateMultipartUploadCommand I got that error

const command = new CreateMultipartUploadCommand({ ...params });
console.log('command', command); // confirm this is print in console
const response = await r2(c).send(command); // this throw the error which catch in catch block

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

cloudflare workers runtime

Reproduction Steps

.

Observed Behavior

Error: The 'cache' field on 'RequestInitializerDict' is not implemented.

Expected Behavior

Don't get that error

Possible Solution

No response

Additional Information/Context

No response

@2820402 2820402 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 19, 2024
@RanVaknin RanVaknin removed the needs-triage This issue or PR still needs to be triaged. label Sep 19, 2024
@RanVaknin
Copy link
Contributor

Hi @2820402 ,

The AWS S3 SDK client is meant to work with S3. We do not offer official support for competing storage offerings like Cloudflare's R2, digital ocean spaces, Min/io and any other S3 clones.

If this exception manifests when interacting with the actual S3 server, please feel free to open a new issue.
Thanks,
Ran~

@RanVaknin RanVaknin closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2024
@2820402
Copy link
Author

2820402 commented Sep 19, 2024

Sorry to bring up this issue again. I found the solution, so I’ll share it in case someone else encounters the same problem: Cloudflare Workers don't support the cache header, so we just need to add this.

export const r2 = (c: RequestT) => {
    const { R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY } = env<ENV>(
        c,
        'workerd'
    );

    return new S3Client({
        region: 'auto',
        endpoint: R2_ENDPOINT,
        credentials: {
            accessKeyId: R2_ACCESS_KEY_ID,
            secretAccessKey: R2_SECRET_ACCESS_KEY,   

        },
        requestHandler: {
            requestInit: () => ({
                cache: undefined, // Disables caching for R2 requests
            }),
        },
    });
};

Copy link

github-actions bot commented Oct 5, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants