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

[credential-provider-cognito-identity] TypeError: Cannot redefine property: localStorage in Node.js v18.16.0 #4807

Closed
3 tasks done
trivikr opened this issue Jun 8, 2023 · 2 comments · Fixed by #4817
Closed
3 tasks done
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@trivikr
Copy link
Member

trivikr commented Jun 8, 2023

Checkboxes for prior research

Describe the bug

The unit tests of middleware-socket throw the following error:

TypeError: Cannot redefine property: localStorage

This may or may not have impact SDK usage. The unit test needs to be fixed.

SDK version number

main

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

18.16.0

Reproduction Steps

Run credential-provider-cognito-identity unit tests in Node.js 18.16.0

Observed Behavior

$ credential-provider-cognito-identity> yarn test
...
 FAIL  src/localStorage.spec.ts
  ● localStorage › should return an IndexedDB-backed cache if possible

    TypeError: Cannot redefine property: localStorage

      11 |   beforeEach(() => {
      12 |     if (window) {
    > 13 |       (window.localStorage as any) = undefined;
         |                                   ^
      14 |     }
      15 |
      16 |     if (self) {

      at Object.<anonymous> (src/localStorage.spec.ts:13:35)

  ● localStorage › should return an IndexedDB-backed cache if possible

    TypeError: Cannot redefine property: localStorage

      21 |   afterEach(() => {
      22 |     if (window) {
    > 23 |       (window.localStorage as any) = storageAtInit;
         |                                   ^
      24 |     }
      25 |
      26 |     if (self) {

      at Object.<anonymous> (src/localStorage.spec.ts:23:35)

  ● localStorage › should return window.localStorage if IndexedDB is undefined but localStorage is available

    TypeError: Cannot redefine property: localStorage

      11 |   beforeEach(() => {
      12 |     if (window) {
    > 13 |       (window.localStorage as any) = undefined;
         |                                   ^
      14 |     }
      15 |
      16 |     if (self) {

      at Object.<anonymous> (src/localStorage.spec.ts:13:35)

  ● localStorage › should return window.localStorage if IndexedDB is undefined but localStorage is available

    TypeError: Cannot redefine property: localStorage

      21 |   afterEach(() => {
      22 |     if (window) {
    > 23 |       (window.localStorage as any) = storageAtInit;
         |                                   ^
      24 |     }
      25 |
      26 |     if (self) {

      at Object.<anonymous> (src/localStorage.spec.ts:23:35)

 PASS  src/fromCognitoIdentity.spec.ts
 PASS  src/fromCognitoIdentityPool.spec.ts

Test Suites: 1 failed, 1 skipped, 5 passed, 6 of 7 total
Tests:       2 failed, 3 skipped, 20 passed, 25 total
Snapshots:   0 total
Time:        3.723 s
Ran all test suites.
error Command failed with exit code 1.

Expected Behavior

$ credential-provider-cognito-identity> yarn test
...
Test Suites: 1 skipped, 6 passed, 6 of 7 total
Tests:       3 skipped, 22 passed, 25 total
Snapshots:   0 total
Time:        3.262 s, estimated 4 s
Ran all test suites.
✨  Done in 3.76s.

Possible Solution

No response

Additional Information/Context

No response

@trivikr trivikr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p2 This is a standard priority issue queued This issues is on the AWS team's backlog and removed needs-triage This issue or PR still needs to be triaged. labels Jun 8, 2023
@yenfryherrerafeliz yenfryherrerafeliz removed the needs-triage This issue or PR still needs to be triaged. label Jun 8, 2023
@kuhe kuhe self-assigned this Jun 8, 2023
@kuhe
Copy link
Contributor

kuhe commented Jun 8, 2023

maybe related nodejs/node#47563

@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 Jun 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants