Skip to content

Login Error messages being suppressed by 'resetActiveSignInState is not defined' error #14585

@DavidCorkill-BiaAnalytical

Description

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

No response

Backend

None

Environment information

Details
# Put output below this line
ystem:
    OS: macOS 26.0
    CPU: (12) arm64 Apple M3 Pro
    Memory: 3.02 GB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - /usr/local/bin/node
    npm: 11.2.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 141.0.7390.54
    Safari: 26.0
  npmPackages:
    @aws-amplify/auth: ^6.12.1 => 6.13.3 (6.16.0)
    @aws-amplify/auth/cognito:  undefined ()
    @aws-amplify/auth/cognito/server:  undefined ()
    @aws-amplify/auth/enable-oauth-listener:  undefined ()
    @aws-amplify/auth/server:  undefined ()
    @aws-sdk/client-s3: ^3.556.0 => 3.782.0 
    @aws-sdk/client-secrets-manager: ^3.569.0 => 3.782.0 
    @aws-sdk/client-sqs: ^3.556.0 => 3.782.0 
    @aws-sdk/credential-providers: ^3.556.0 => 3.782.0 
    @babel/plugin-proposal-private-property-in-object: ^7.21.11 => 7.21.11 (7.21.0-placeholder-for-preset-env.2)
    @chakra-ui/icons: ^2.1.1 => 2.2.4 
    @chakra-ui/react: ^2.8.2 => 2.10.7 
    @craco/craco: ^7.1.0 => 7.1.0 
    @emotion/react: ^11.11.4 => 11.14.0 
    @emotion/styled: ^11.11.5 => 11.14.0 
    @react-three/drei: ^9.99.0 => 9.122.0 
    @react-three/fiber: ^8.15.16 => 8.18.0 
    @testing-library/jest-dom: ^5.17.0 => 5.17.0 
    @testing-library/react: ^13.4.0 => 13.4.0 
    @testing-library/user-event: ^13.5.0 => 13.5.0 
    amazon-cognito-identity-js: ^6.3.12 => 6.3.15 
    amazon-cognito-identity-js/internals:  undefined ()
    awaitable-timers: ^1.0.0 => 1.0.0 
    aws-amplify: ^6.15.7 => 6.15.7 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    aws-jwt-verify: ^4.0.1 => 4.0.1 
    aws-sdk: ^2.1600.0 => 2.1692.0 
    axios: ^1.6.8 => 1.8.4 
    browserify-zlib: ^0.2.0 => 0.2.0 
    buffer: ^6.0.3 => 6.0.3 (4.9.2)
    chart.js: ^4.4.7 => 4.4.8 
    chart.js-auto:  undefined ()
    chart.js-helpers:  undefined ()
    country-flag-icons: ^1.5.19 => 1.5.19 
    crypto-js: ^4.2.0 => 4.2.0 
    d3-scale: ^4.0.2 => 4.0.2 (3.3.0)
    d3-scale-chromatic: ^3.1.0 => 3.1.0 
    date-fns: ^4.1.0 => 4.1.0 
    eslint: ^8.57.1 => 8.57.1 
    formik: ^2.4.6 => 2.4.6 
    framer-motion: ^11.1.3 => 11.18.2 
    js-cookie: ^3.0.5 => 3.0.5 (2.2.1)
    jwt-decode: ^4.0.0 => 4.0.0 
    leaflet: ^1.9.4 => 1.9.4 
    lucide-react: ^0.471.1 => 0.471.2 
    papaparse: ^5.4.1 => 5.5.2 
    plotly.js: ^3.0.1 => 3.0.1 
    plotly.js-dist: ^2.35.3 => 2.35.3 
    plotly.js-dist-min: ^3.0.1 => 3.0.1 
    process: ^0.11.10 => 0.11.10 
    qrcode.react: ^4.2.0 => 4.2.0 
    querystring-es3: ^0.2.1 => 0.2.1 
    react: ^18.2.0 => 18.3.1 
    react-beautiful-dnd: ^13.1.1 => 13.1.1 
    react-calendar: ^6.0.0 => 6.0.0 
    react-chartjs-2: ^5.3.0 => 5.3.0 
    react-charts: ^3.0.0-beta.57 => 3.0.0-beta.57 
    react-cookie: ^7.1.4 => 7.2.2 
    react-dom: ^18.2.0 => 18.3.1 
    react-dropzone: ^14.3.5 => 14.3.8 
    react-grid-layout: ^1.5.0 => 1.5.1 
    react-hook-form: ^7.51.5 => 7.55.0 
    react-icons: ^5.1.0 => 5.5.0 
    react-leaflet: ^4.2.1 => 4.2.1 
    react-lorem-ipsum: ^1.4.10 => 1.4.10 
    react-markdown: ^8.0.5 => 8.0.5 
    react-plotly.js: ^2.6.0 => 2.6.0 
    react-quill: ^2.0.0 => 2.0.0 
    react-router-dom: ^6.22.3 => 6.30.0 
    react-scripts: 5.0.1 => 5.0.1 
    react-select: ^5.10.1 => 5.10.1 
    react-simple-maps: ^3.0.0 => 3.0.0 
    react-to-print: ^3.1.0 => 3.1.0 
    react-virtualized-auto-sizer: ^1.0.25 => 1.0.26 
    react-window: ^1.8.11 => 1.8.11 
    recharts: ^2.12.6 => 2.15.2 
    rehype-raw: ^6.1.1 => 6.1.1 
    remark-gfm: ^3.0.1 => 3.0.1 
    remark-parse: ^11.0.0 => 11.0.0 (10.0.2)
    stream-browserify: ^3.0.0 => 3.0.0 
    string_decoder: ^1.3.0 => 1.3.0 (0.10.31, 1.1.1)
    three: ^0.166.0 => 0.166.0 (0.170.0)
    timers: ^0.1.1 => 0.1.1 
    topojson-client: ^3.1.0 => 3.1.0 
    util: ^0.12.5 => 0.12.5 
    uuid: ^11.0.3 => 11.1.0 (9.0.1, 8.0.0, 8.3.2)
    web-vitals: ^2.1.4 => 2.1.4 
    yup: ^1.5.0 => 1.6.1 
  npmGlobalPackages:
    corepack: 0.31.0
    npm: 11.2.0

Describe the bug

When attempting to sign in with invalid credentials using signIn() from aws-amplify/auth, Cognito correctly returns authentication error responses, but the Amplify library throws a ReferenceError: resetActiveSignInState is not defined which masks the actual authentication error. This prevents proper error handling and user feedback.

This bug prevents developers from:

  1. Providing specific, user-friendly error messages (e.g., "User not found" vs "Incorrect password")
  2. Implementing proper error handling logic based on error types
  3. Distinguishing between different authentication failure scenarios

The underlying Cognito API is working correctly and returning appropriate error codes, but the Amplify library is throwing an unrelated error that obscures the actual authentication failure reason.

Expected behavior

When Cognito returns authentication errors, the signIn() function should propagate those errors (with __type and message properties intact) to the catch block, allowing developers to handle them appropriately.

The error object should contain:

  • error.name or error.__type: The Cognito error type (e.g., "UserNotFoundException", "NotAuthorizedException")
  • error.message: The Cognito error message
  • Proper error codes for switch-case handling

Reproduction steps

  1. Configure Amplify Auth with Cognito
  2. Call signIn() with credentials that trigger a Cognito authentication error
  3. Observe that a ReferenceError is thrown instead of the expected Cognito error

Code Snippet

import { signIn } from "aws-amplify/auth";

const handleSignIn = async (email, password) => {
  try {
    const { isSignedIn, nextStep } = await signIn({
      username: email,
      password,
    });
    // ... handle success
  } catch (error) {
    // Expected to catch NotAuthorizedException or UserNotFoundException
    // Instead catches: ReferenceError: resetActiveSignInState is not defined
    console.error("Error:", error);
  }
};

Log output

Details
ReferenceError: resetActiveSignInState is not defined
    at signInWithSRP (signInWithSRP.ts:73:1)

Error Object Properties:

  • error.name: "ReferenceError"
  • error.code: undefined
  • error.__type: undefined
  • error.message: "resetActiveSignInState is not defined"

Full Stack Trace

AuthContext.jsx:588  POST https://cognito-idp.eu-west-1.amazonaws.com/ 400 (Bad Request)
fetchTransferHandler @ fetch.ts:11
composedHandler @ composeTransferHandler.ts:13
amzSdkRequestHeaderMiddleware @ amzSdkRequestHeaderMiddleware.ts:19
retryMiddleware @ retryMiddleware.ts:26
amzSdkInvocationIdHeaderMiddleware @ amzSdkInvocationIdHeaderMiddleware.ts:20
userAgentMiddleware @ middleware.ts:20
(anonymous) @ composeTransferHandler.ts:19
composedHandler @ composeTransferHandler.ts:13
disableCacheMiddleware @ cognitoUserPoolTransferHandler.ts:10
(anonymous) @ composeTransferHandler.ts:19
(anonymous) @ composeServiceApi.ts:52
await in (anonymous)
handlePasswordSRP @ handlePasswordSRP.ts:56
await in handlePasswordSRP
handleUserSRPAuthFlow @ signInHelpers.ts:270
signInWithSRP @ signInWithSRP.ts:38
signIn @ signIn.ts:41
await in signIn
handleSignIn @ AuthContext.jsx:588

Raw error object: ReferenceError: resetActiveSignInState is not defined
    at signInWithSRP (signInWithSRP.ts:73:1)
    at async handleSignIn (AuthContext.jsx:588:1)

Network Response

Cognito API correctly returns the appropriate error:

POST https://cognito-idp.eu-west-1.amazonaws.com/ 400 (Bad Request)

Response Body:
{
  "__type": "UserNotFoundException",
  "message": "User does not exist."
}

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

Test Scenarios

Scenario 1: Non-existent User

  • Input: Email that doesn't exist in user pool, any password
  • Expected Cognito Response:
{
  "__type": "UserNotFoundException",
  "message": "User does not exist."
}
  • Expected Behavior: Catch block receives UserNotFoundException error
  • Actual Behavior: Catch block receives ReferenceError: resetActiveSignInState is not defined

Scenario 2: Wrong Password

  • Input: Valid email, incorrect password
  • Expected Cognito Response:
{
  "__type": "NotAuthorizedException",
  "message": "Incorrect username or password."
}
  • Expected Behavior: Catch block receives NotAuthorizedException error
  • Actual Behavior: Catch block receives ReferenceError: resetActiveSignInState is not defined

Actual Error Received

ReferenceError: resetActiveSignInState is not defined
    at signInWithSRP (signInWithSRP.ts:73:1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthRelated to Auth components/categoryfeature-requestRequest a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions