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

v1.0.0-gamma.7 / #1420 causes Region is missing errors #1466

Closed
roderik opened this issue Aug 26, 2020 · 3 comments · Fixed by #1471
Closed

v1.0.0-gamma.7 / #1420 causes Region is missing errors #1466

roderik opened this issue Aug 26, 2020 · 3 comments · Fixed by #1471
Assignees
Labels
bug This issue is a bug.

Comments

@roderik
Copy link

roderik commented Aug 26, 2020

Describe the bug

v1.0.0-gamma.7 and presumably #1420 broke perfectly working S3 client implementation.

  console.error
    Error: Region is missing
        at default (/Users/roderik/Development/bpaas-launchpad/node_modules/@aws-sdk/config-resolver/src/RegionConfig.ts:12:4)
        at /Users/roderik/Development/bpaas-launchpad/node_modules/@aws-sdk/node-config-provider/src/fromStatic.ts:9:59
        at step (/Users/roderik/Development/bpaas-launchpad/node_modules/tslib/tslib.js:141:27)
        at Object.next (/Users/roderik/Development/bpaas-launchpad/node_modules/tslib/tslib.js:122:57)
        at /Users/roderik/Development/bpaas-launchpad/node_modules/tslib/tslib.js:115:75
        at new Promise (<anonymous>)
        at Object.__awaiter (/Users/roderik/Development/bpaas-launchpad/node_modules/tslib/tslib.js:111:16)
        at /Users/roderik/Development/bpaas-launchpad/node_modules/@aws-sdk/node-config-provider/src/fromStatic.ts:9:56
        at /Users/roderik/Development/bpaas-launchpad/node_modules/@aws-sdk/node-config-provider/node_modules/@aws-sdk/property-provider/src/chain.ts:23:19

      at process.uncaught (../../node_modules/@jest/core/node_modules/jest-jasmine2/build/jasmine/Env.js:249:21)
      at processEmit [as emit] (../../node_modules/signal-exit/index.js:161:32)

Reverting back to gamma.6 makes these errors go away.

The code we use to initialize S3 is

export enum EKSRegion {
  EUROPE = 'eu-west-3',
  UNITED_STATES = 'us-east-2',
  INDIA = 'ap-south-1',
  SINGAPORE = 'ap-southeast-1',
}
    this.s3 = new S3({
      credentials: {
        accessKeyId: config.providers.EKS.accessKeyId,
        secretAccessKey: config.providers.EKS.secretAccessKey,
      },
      region: EKSRegion.EUROPE,
    });

SDK version number

v1.0.0-gamma.7

Is the issue in the browser/Node.js/ReactNative?

Node.js

Details of the browser/Node.js/ReactNative version

v14.7.0

@AllanZhengYP
Copy link
Contributor

Hi @roderik

I can reproduce this issue. The issue is caused by the default region provider of the clients. We will fix this issue shortly, for now you can keep on gamma.6 version. Here's the root cause:

S3 loads the region from local INI files and environment variables by default:

region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: new NodeHttpHandler(),

If you provide a region config, it will overwrite the default region provider above. What happens here is that when the default region provider function is created, it already inspected the local INI files and environment vairiables to load the region and would throw if cannot find the region. If region can be found, it will memoize the value and prevent loading it in every evoke.

export const memoize: MemoizeOverload = <T>(
provider: Provider<T>,
isExpired?: (resolved: T) => boolean,
requiresRefresh?: (resolved: T) => boolean
): Provider<T> => {
if (isExpired === undefined) {
// This is a static memoization; no need to incorporate refreshing
const result = provider();
return () => result;
}

However, the expected behavior of memoize() should be loading the value after first evoke instead of immediately.

@AllanZhengYP
Copy link
Contributor

This fix has been merged into master. For now, as a workaround, you can set the region before instantiate the client, like:

process.env.AWS_REGION = "us-west-2";
const client = new S3({
  credentials: {
    accessKeyId: "***",
    secretAccessKey: "***"
  }
});
await client.putObject(params);

@github-actions
Copy link

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 Jan 17, 2021
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

Successfully merging a pull request may close this issue.

2 participants