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

Unable to get configuration from AppConfig on browser #2587

Closed
abel30567 opened this issue Jul 16, 2021 · 5 comments · Fixed by #2601
Closed

Unable to get configuration from AppConfig on browser #2587

abel30567 opened this issue Jul 16, 2021 · 5 comments · Fixed by #2601
Assignees
Labels
bug This issue is a bug.

Comments

@abel30567
Copy link

abel30567 commented Jul 16, 2021

Describe the bug

@aws-sdk/client-appconfig is referencing [email protected] and that package does not implement __spreadArray. When loading the package on a React app I see the following warnings

"export '__spreadArray' was not found in 'tslib'

I am not able to fetch the App Configs

Your environment

SDK version number

@aws-sdk/[email protected]

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

Browser

Details of the browser/Node.js/ReactNative version

Chrome: 91.0.4472.164
node -v
v10.22.0

Steps to reproduce

export const getAppConfigs = async (
  code: String,
): Object => {
  try {
    const Client = new AppConfigClient({
      region: <REGION>,
      credentials: {
        accessKeyId: <ACCESS_KEY>,
        secretAccessKey: <SECRET_KEY>
      }
    });
    const command = new GetConfigurationCommand({
      Application: `App-${code}`,
      ClientId: `App-${code}-Client`,
      Configuration: "AppConfig",
      Environment: "Dev"
    });
    const response = await Client.send(command); // Fails here
    let parsedConfigs = JSON.parse(
      String.fromCharCode.apply(null, response.Content)
    );

  } catch (error) {
    throw error;
  }
};

Observed behavior

When I send a request I get the following error

TypeError: Object(...) is not a function
    at MiddlewareStack.js:110
    at Array.reduce (<anonymous>)
    at getMiddlewareList (MiddlewareStack.js:108)
    at Object.resolve (MiddlewareStack.js:190)
    at GetConfigurationCommand../node_modules/@aws-sdk/client-appconfig/dist/es/commands/GetConfigurationCommand.js.GetConfigurationCommand.resolveMiddleware (GetConfigurationCommand.js:64)
    at AppConfigClient../node_modules/@aws-sdk/client-appconfig/node_modules/@aws-sdk/smithy-client/dist/es/client.js.Client.send (client.js:10)
    at _callee3$ (Auth.js:122)

Expected behavior

Expected to receive the AppConfig blob response.

Screenshots

According to browser dev tools the MiddlewareStack.js:110 depends on __spreadArray
image

Additional context

I replaced tslib from @aws-sdk/[email protected] manually with version [email protected] and the following warning went away.

"export '__spreadArray' was not found in 'tslib'

However, the request kept on failing when trying to fetch the AppConfigs

@abel30567 abel30567 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 16, 2021
@AllanZhengYP
Copy link
Contributor

The __spreadArray is only available after tslib 2.1.0, however, most of the SDK package targets tslib ^2.0.0. I will put up a fix to bump up the tslib version. We should have bump up the tslib everytime we upgrade our TypeScript version. Luckily TypeScript team posted the compatibility table recently: microsoft/tslib#148

@AllanZhengYP AllanZhengYP removed the needs-triage This issue or PR still needs to be triaged. label Jul 19, 2021
@AllanZhengYP AllanZhengYP self-assigned this Jul 19, 2021
@AllanZhengYP
Copy link
Contributor

AllanZhengYP commented Jul 19, 2021

As a short-term workaround, you can specify "tslib": "^2.3.0"(or other version >= 2.1.0) in your dependencies. It will be picked up by v3 SDK

@abel30567
Copy link
Author

I got the warning for the __spreadArray to go away but I am getting CORS error when I try to fetch the AppConfig from the browser

@AllanZhengYP
Copy link
Contributor

Hi @abel30567, Can you open a separate issue for it? We will address it separately.

@github-actions
Copy link

github-actions bot commented Aug 5, 2021

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 Aug 5, 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