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: Cannot read property 'headers' of undefined in Client.js when offline #389

Closed
WolfWalter opened this issue Mar 1, 2018 · 5 comments
Labels
Auth Related to Auth components/category feature-request Request a new feature

Comments

@WolfWalter
Copy link

WolfWalter commented Mar 1, 2018

Do you want to request a feature or report a bug?
bug

What is the current behavior?
When CognitoUser refreshSession gets called while being offline, Client.js on line 67 tries to use an empty response object resulting in an uncaught error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'headers' of undefined
TypeError: Cannot read property 'headers' of undefined
    at Client.js:67
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4630)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4621)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at Client.js:67
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4630)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4621)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at c (polyfills.js:3)
    at polyfills.js:3
    at t.invokeTask (polyfills.js:3)
    at Object.onInvokeTask (core.js:4621)
    at t.invokeTask (polyfills.js:3)
    at r.runTask (polyfills.js:3)
    at o (polyfills.js:3)
    at <anonymous>

What is the expected behavior?
Returning null or throwing an error / rejecting.

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
aws-amplify 0.2.9
Linux (Ubuntu 16.04) in Chrome 64 and Electron 1.8.2

@WolfWalter WolfWalter changed the title Error: Cannot read property 'headers' of undefined after Auth.currentUserInfo() when offline Error: Cannot read property 'headers' of undefined in Client.js when offline Mar 1, 2018
@manueliglesias manueliglesias added the investigating This issue is being investigated label Mar 1, 2018
@davideickhoff
Copy link

the issue is quite obvious and easy to see in the code (Client.js)

59        // Taken from aws-sdk-js/lib/protocol/json.js
60        const code = (response.headers.get('x-amzn-errortype') || 'UnknownError').split(':')[0];

the response object is defined with let response and if the fetch call fails, there is no assignment to the response object.

In one of our applications I have customer reports (sent through sentry.io) which describe the same error. I am not sure if it is related to an offline issue (their browser was able to send me the sentry.io report, so they should have been online somehow). It may occur when switching networks or trying to refresh tokens.

@ArmorDarks
Copy link

Just stumbled into the same issue. The most disappointing part is that right now there is no way to catch that error.

@maro1987
Copy link

I solved it by downgrading amazon-cognito-identity-js to version 1.29.0

@powerful23 powerful23 added the Cognito Related to cognito issues label Apr 2, 2018
@mlabieniec mlabieniec added Auth Related to Auth components/category enhancement and removed investigating This issue is being investigated labels Apr 13, 2018
@mlabieniec mlabieniec added this to Backlog in amazon-cognito-identity-js via automation Apr 13, 2018
@mlabieniec mlabieniec added feature-request Request a new feature and removed Cognito Related to cognito issues enhancement labels Apr 19, 2018
@elorzafe
Copy link
Contributor

This issue was fixed on this PR #605

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category feature-request Request a new feature
Projects
No open projects
Development

No branches or pull requests

9 participants