amplify-js: UnexpectedSignInInterruptionException during sign-in affecting a subset of users after upgrade to Amplify v6

Before opening, please confirm:

JavaScript Framework

React, Next.js

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Other

Environment information

  System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12500
    Memory: 7.88 GB / 31.77 GB
  Binaries:
    Node: 20.9.0 - ~\AppData\Local\Volta\tools\image\node\20.9.0\node.EXE
    Yarn: 1.22.19 - ~\AppData\Local\Volta\tools\image\yarn\1.22.19\bin\yarn.CMD
    npm: 10.1.0 - ~\AppData\Local\Volta\tools\image\node\20.9.0\npm.CMD
  Browsers:
    Edge: Chromium (122.0.2365.92)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @ampproject/toolbox-optimizer:  undefined ()
    @aws-amplify/adapter-nextjs: 1.0.23 => 1.0.23 
    @aws-amplify/adapter-nextjs/api:  undefined ()
    @aws-amplify/adapter-nextjs/data:  undefined ()
    @babel/core:  undefined ()
    @babel/runtime:  7.22.5
    @edge-runtime/cookies:  4.1.0
    @edge-runtime/ponyfill:  2.4.2
    @edge-runtime/primitives:  4.1.0
    @grafana/faro-core: ^1.0.5 => 1.4.2
    @grafana/faro-web-sdk: ^1.0.2 => 1.4.2
    @hapi/accept:  undefined ()
    @hookform/resolvers: ^2.9.10 => 2.9.11
    @hookform/resolvers/ajv:  1.0.0
    @hookform/resolvers/class-validator:  1.0.0
    @hookform/resolvers/computed-types:  1.0.0
    @hookform/resolvers/io-ts:  1.0.0
    @hookform/resolvers/joi:  1.0.0
    @hookform/resolvers/nope:  1.0.0
    @hookform/resolvers/superstruct:  1.0.0
    @hookform/resolvers/typanion:  1.0.0
    @hookform/resolvers/vest:  1.0.0
    @hookform/resolvers/yup:  1.0.0
    @hookform/resolvers/zod:  1.0.0
    @internationalized/date: 3.5.2 => 3.5.2
    @jest/globals: ^29.5.0 => 29.7.0
    @mswjs/interceptors:  undefined ()
    @napi-rs/triples:  undefined ()
    @next/font:  undefined ()
    @next/react-dev-overlay:  undefined ()
    @openapitools/openapi-generator-cli: ^2.9.0 => 2.12.0
    @opentelemetry/api:  undefined ()
    @radix-ui/react-dropdown-menu: ^2.0.6 => 2.0.6
    @radix-ui/react-navigation-menu: ^1.1.4 => 1.1.4
    @react-aria/utils: 3.23.2 => 3.23.2
    @react-stately/utils: 3.9.1 => 3.9.1
    @rjsf/core: 5.18.1 => 5.18.1
    @rjsf/utils: 5.18.1 => 5.18.1
    @rjsf/validator-ajv8: 5.18.1 => 5.18.1
    @svgr/webpack: 6.5.1 => 6.5.1
    @tanstack/eslint-plugin-query: 5.27.7 => 5.27.7
    @tanstack/query-codemods:  4.24.3
    @tanstack/react-query: 5.28.0 => 5.28.0
    @testing-library/jest-dom: ^5.16.5 => 5.17.0
    @testing-library/react: ^13.4.0 => 13.4.0
    @types/adm-zip: ^0.5.5 => 0.5.5
    @types/lodash: 4.17.0 => 4.17.0
    @types/mime-types: ^2.1.1 => 2.1.4
    @types/node: 18.11.18 => 18.11.18 (20.11.28)
    @types/object-hash: ^3.0.5 => 3.0.6
    @types/qs: ^6.9.12 => 6.9.12
    @types/react: 18.2.65 => 18.2.65 (18.2.66)
    @types/react-beforeunload: ^2.1.1 => 2.1.5
    @types/react-dom: 18.2.22 => 18.2.22
    @types/traverse: ^0.6.32 => 0.6.36
    @types/uuid: ^9.0.1 => 9.0.8
    @types/xml2js: ^0.4.14 => 0.4.14
    @typescript-eslint/eslint-plugin: 7.2.0 => 7.2.0
    @typescript-eslint/parser: 7.2.0 => 7.2.0 (6.21.0)
    @vercel/nft:  undefined ()
    @vercel/og:  0.6.2
    acorn:  undefined ()
    add-to-calendar-button-react: ^2.2.3 => 2.6.6
    adm-zip: ^0.5.10 => 0.5.12
    ajv: 8.12.0 => 8.12.0 (6.12.6)
    ajv-formats: 2.1.1 => 2.1.1
    amphtml-validator:  undefined ()
    anser:  undefined ()
    arg:  undefined ()
    assert:  undefined ()
    async-retry:  undefined ()
    async-sema:  undefined ()
    autoprefixer: 10.4.18 => 10.4.18
    aws-amplify: 6.0.23 => 6.0.23
    aws-amplify/adapter-core:  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/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 ()
    axios: ^1.4.0 => 1.6.7 (1.6.5)
    babel-packages:  undefined ()
    browserify-zlib:  undefined ()
    browserslist:  undefined ()
    buffer:  undefined ()
    bytes:  undefined ()
    ci-info:  undefined ()
    classnames: 2.5.1 => 2.5.1
    cli-select:  undefined ()
    client-only:  0.0.1
    comment-json:  undefined ()
    compression:  undefined ()
    conditional-wrap: ^1.0.2 => 1.0.2
    conf:  undefined ()
    constants-browserify:  undefined ()
    content-disposition:  undefined ()
    content-type:  undefined ()
    cookie:  undefined ()
    cross-spawn:  undefined ()
    crypto-browserify:  undefined ()
    css.escape:  undefined ()
    data-uri-to-buffer:  undefined ()
    debug:  undefined ()
    devalue:  undefined ()
    domain-browser:  undefined ()
    edge-runtime:  undefined ()
    eslint: 8.57.0 => 8.57.0
    eslint-config-adjunct: 4.13.0 => 4.13.0
    eslint-config-airbnb: 19.0.4 => 19.0.4
    eslint-config-airbnb-typescript: 18.0.0 => 18.0.0
    eslint-config-auto: 0.9.0 => 0.9.0
    eslint-config-next: 14.1.3 => 14.1.3
    eslint-config-prettier: 9.1.0 => 9.1.0
    eslint-plugin-array-func: 5.0.1 => 5.0.1
    eslint-plugin-const-case: 1.2.2 => 1.2.2
    eslint-plugin-eslint-comments: 3.2.0 => 3.2.0
    eslint-plugin-html: 8.0.0 => 8.0.0
    eslint-plugin-import: 2.29.1 => 2.29.1
    eslint-plugin-jest: 27.9.0 => 27.9.0
    eslint-plugin-jest-async: 1.0.3 => 1.0.3
    eslint-plugin-jest-dom: 5.1.0 => 5.1.0
    eslint-plugin-json: 3.1.0 => 3.1.0
    eslint-plugin-lodash: 7.4.0 => 7.4.0
    eslint-plugin-lodash-fp: 2.2.0-a1 => 2.2.0a1
    eslint-plugin-markdown: 4.0.1 => 4.0.1
    eslint-plugin-no-constructor-bind: 2.0.4 => 2.0.4
    eslint-plugin-no-secrets: 0.8.9 => 0.8.9
    eslint-plugin-no-unsanitized: 4.0.2 => 4.0.2
    eslint-plugin-no-use-extend-native: 0.5.0 => 0.5.0
    eslint-plugin-optimize-regex: 1.2.1 => 1.2.1
    eslint-plugin-pii: 1.0.2 => 1.0.2
    eslint-plugin-prettier: 5.1.3 => 5.1.3
    eslint-plugin-promise: 6.1.1 => 6.1.1
    eslint-plugin-react-hooks: 4.6.0 => 4.6.0
    eslint-plugin-scanjs-rules: 0.2.1 => 0.2.1
    eslint-plugin-security: 2.1.1 => 2.1.1
    eslint-plugin-simple-import-sort: 12.0.0 => 12.0.0
    eslint-plugin-sonarjs: 0.24.0 => 0.24.0
    eslint-plugin-switch-case: 1.1.2 => 1.1.2
    eslint-plugin-tailwindcss: 3.15.1 => 3.15.1
    eslint-plugin-testing-library: 6.2.0 => 6.2.0
    eslint-plugin-unicorn: 51.0.1 => 51.0.1
    eslint-plugin-xss: 0.1.12 => 0.1.12
    events:  undefined ()
    expr-eval: ^2.0.2 => 2.0.2
    find-cache-dir:  undefined ()
    find-up:  undefined ()
    focus-trap-react: ^10.2.3 => 10.2.3
    fresh:  undefined ()
    get-orientation:  undefined ()
    glob:  undefined ()
    gzip-size:  undefined ()
    http-proxy:  undefined ()
    http-proxy-agent:  undefined ()
    https-browserify:  undefined ()
    https-proxy-agent:  undefined ()
    husky: ^8.0.1 => 8.0.3
    i18next: 23.10.1 => 23.10.1
    icss-utils:  undefined ()
    ignore-loader:  undefined ()
    image-size:  undefined ()
    is-animated:  undefined ()
    is-docker:  undefined ()
    is-wsl:  undefined ()
    jest: ^29.5.0 => 29.7.0
    jest-each: ^29.7.0 => 29.7.0
    jest-environment-jsdom: ^29.5.0 => 29.7.0
    jest-worker:  undefined ()
    js-cookie: ^3.0.1 => 3.0.5 (2.2.1)
    json-schema: ^0.4.0 => 0.4.0
    json5:  undefined ()
    jsonwebtoken:  undefined ()
    lint-staged: ^15.2.2 => 15.2.2
    loader-runner:  undefined ()
    loader-utils:  undefined ()
    lodash: 4.17.21 => 4.17.21
    lodash.curry:  undefined ()
    lru-cache:  undefined ()
    micromatch:  undefined ()
    mime-types: ^2.1.35 => 2.1.35
    mini-css-extract-plugin:  undefined ()
    nanoid:  undefined ()
    native-url:  undefined ()
    neo-async:  undefined ()
    next: 14.1.3 => 14.1.3
    next-i18next: 15.2.0 => 15.2.0
    next-i18next-create-client:  undefined ()
    next-plausible: ^3.12.0 => 3.12.0
    node-fetch:  undefined ()
    node-html-parser:  undefined ()
    nuqs: ^1.17.0 => 1.17.1
    object-hash: ^3.0.0 => 3.0.0
    ora:  undefined ()
    os-browserify:  undefined ()
    p-limit:  undefined ()
    path-browserify:  undefined ()
    pino: ^8.16.2 => 8.19.0
    pino-pretty: ^10.2.3 => 10.3.1
    platform:  undefined ()
    postcss: 8.4.35 => 8.4.35 (8.4.31)
    postcss-flexbugs-fixes:  undefined ()
    postcss-modules-extract-imports:  undefined ()
    postcss-modules-local-by-default:  undefined ()
    postcss-modules-scope:  undefined ()
    postcss-modules-values:  undefined ()
    postcss-preset-env:  undefined ()
    postcss-safe-parser:  undefined ()
    postcss-scss:  undefined ()
    postcss-value-parser:  undefined ()
    pre-commit: ^1.2.2 => 1.2.2
    prettier: 3.2.5 => 3.2.5
    prettier-plugin-tailwindcss: 0.5.12 => 0.5.12
    pretty-bytes: ^6.1.1 => 6.1.1
    process:  undefined ()
    punycode:  undefined ()
    qs: ^6.11.2 => 6.12.0
    querystring-es3:  undefined ()
    raw-body:  undefined ()
    react: 18.2.0 => 18.2.0
    react-aria: 3.32.1 => 3.32.1
    react-aria-components: 1.1.1 => 1.1.1
    react-beforeunload: ^2.6.0 => 2.6.0
    react-builtin:  undefined ()
    react-cookie-consent: 7.5.0 => 7.5.0
    react-dom: 18.2.0 => 18.2.0
    react-dom-builtin:  undefined ()
    react-dom-experimental-builtin:  undefined ()
    react-experimental-builtin:  undefined ()
    react-hook-form: ^7.42.1 => 7.51.0
    react-i18next: 14.1.0 => 14.1.0
    react-is:  18.2.0
    react-loading-skeleton: ^3.3.1 => 3.4.0
    react-markdown: ^9.0.0 => 9.0.1
    react-refresh:  0.12.0
    react-remove-scroll: ^2.5.5 => 2.5.7 (2.5.5)
    react-resize-detector: ^8.0.3 => 8.1.0
    react-select: ^5.8.0 => 5.8.0
    react-server-dom-turbopack-builtin:  undefined ()
    react-server-dom-turbopack-experimental-builtin:  undefined ()
    react-server-dom-webpack-builtin:  undefined ()
    react-server-dom-webpack-experimental-builtin:  undefined ()
    react-simple-snackbar: ^1.1.11 => 1.1.11
    react-stately: 3.30.1 => 3.30.1
    react-turnstile: ^1.1.0 => 1.1.3
    react-usestateref: ^1.0.8 => 1.0.8
    regenerator-runtime:  0.13.4
    rehype-raw: ^7.0.0 => 7.0.0
    rehype-sanitize: ^6.0.0 => 6.0.0
    remark-directive: ^3.0.0 => 3.0.0
    remark-directive-rehype: ^0.4.2 => 0.4.2
    remark-gfm: ^4.0.0 => 4.0.0
    remark-supersub: ^1.0.0 => 1.0.0
    rooks: 5.11.8 => 5.11.8
    sass-loader:  undefined ()
    scheduler-builtin:  undefined ()
    scheduler-experimental-builtin:  undefined ()
    schema-utils:  undefined ()
    semver:  undefined ()
    send:  undefined ()
    server-only:  0.0.1
    setimmediate:  undefined ()
    sharp: 0.33.2 => 0.33.2
    shell-quote:  undefined ()
    slugify: ^1.6.6 => 1.6.6
    source-map:  undefined ()
    stacktrace-parser:  undefined ()
    stream-browserify:  undefined ()
    stream-http:  undefined ()
    string-hash:  undefined ()
    string_decoder:  undefined ()
    strip-ansi:  undefined ()
    superstruct:  undefined ()
    tailwind-merge: 2.2.1 => 2.2.1
    tailwind-scrollbar-hide: 1.1.7 => 1.1.7
    tailwindcss: 3.4.1 => 3.4.1
    tar:  undefined ()
    terser:  undefined ()
    text-table:  undefined ()
    timers-browserify:  undefined ()
    transport:  0.0.1
    traverse: ^0.6.7 => 0.6.8
    tty-browserify:  undefined ()
    typescript: 5.4.2 => 5.4.2
    ua-parser-js:  undefined ()
    unistore:  undefined ()
    universal-cookie: ^4.0.4 => 4.0.4
    usehooks-ts: 2.16.0 => 2.16.0
    util:  undefined ()
    uuid: ^9.0.0 => 9.0.1 (8.3.2)
    vm-browserify:  undefined ()
    watchpack:  undefined ()
    web-vitals:  undefined ()
    webpack:  undefined ()
    webpack-sources:  undefined ()
    ws:  undefined ()
    xml2js: ^0.6.2 => 0.6.2
    yet-another-react-lightbox: ^3.15.4 => 3.17.1
    zod:  undefined ()
  npmGlobalPackages:
    corepack: 0.20.0
    npm: 10.1.0



Describe the bug

After update to Amplify V6, part of our userbase started reporting being not able to sign in. In the logs we’ve found that our users are getting UnexpectedSignInInterruptionException (150 instances in two weeks since the update, with thousands of active users). https://github.com/aws-amplify/amplify-js/blob/0ddaa3cc1257f5f006e5c3d534e19e866521c4bd/packages/auth/src/providers/cognito/utils/dispatchSignedInHubEvent.ts#L30

It was not possible to Google any instance of anyone getting the same error, also there are no issues mentioning this either. The provided remedy in the recoverySuggestion is to “ensure cookies can be correctly set from your server”. I suspect that if our server wouldn’t be able to set cookies correctly, it would happen in 100% cases, therefore I think it is a bug.

After trying on 10s of users, we were not able to reproduce the issue ourselves, however our project is completely open source which makes it easy to share the code:

Amplify config: https://github.com/bratislava/konto.bratislava.sk/blob/ba71f78deed6202541dec776efeddc239be3766e/next/frontend/utils/amplifyConfig.ts Login sequence: https://github.com/bratislava/konto.bratislava.sk/blob/ba71f78deed6202541dec776efeddc239be3766e/next/pages/prihlasenie.tsx#L36 Environmental variables: https://github.com/bratislava/konto.bratislava.sk/blob/ba71f78deed6202541dec776efeddc239be3766e/next/.env.bratiska-cli-build.prod package.json: https://github.com/bratislava/konto.bratislava.sk/blob/ba71f78deed6202541dec776efeddc239be3766e/next/package.json Amplify config before the update: https://github.com/bratislava/konto.bratislava.sk/blob/f9e2ec6c0f57b0fb8ff871b0d3490d58f6ac6acf/next/frontend/utils/amplify.ts Login sequence before the update: https://github.com/bratislava/konto.bratislava.sk/blob/f9e2ec6c0f57b0fb8ff871b0d3490d58f6ac6acf/next/pages/prihlasenie.tsx#L43

Thank you.

Expected behavior

The authentication process should successfully complete without any errors, allowing users access to their accounts without any interruptions or discrepancies in the sign-in flow.

Reproduction steps

As the issue has not been reproducible on our end despite attempts with tens of users, we’re unable to provide specific steps that consistently trigger the UnexpectedSignInInterruptionException. Below are the general steps a user would follow, which for some results in the error:

  1. Navigate to the sign-in page of our application.
  2. Enter valid user credentials (username and password).
  3. Click the “Prihlásiť sa” button to initiate the authentication process.

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


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

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@cwomack We were able to contact some of the users that it’s happening to and with high certainty we can tell that it is device specific issue (however the user agents don’t differ from successfully sign-ins), the same people were able to sign-in on a different device.

Also, it seems that these are not new users, so we think some residual cookies / local storage values can interfere with login, so we are now testing this approach: https://github.com/bratislava/konto.bratislava.sk/pull/924/files

We will inform you if it worked.

@erinleigh90 (Un)fortunately we haven’t had any occurrences of the error since 5th March (with couple of thousands successful sign-ins). We deployed this on 8th March, so we cannot evaluate.

Updated info - we’ve tried changing the pw and logging into the 2bf74b91-22f2-46c4-b342-74ede104a7e4 user account and could not reproduce the issue. Waiting on confirmation from the user whether the issue keeps happening on their side.

We’ve added the user agent info to our production logs, if we catch a new instance of the issue we’ll be able to provide those.

@HuiSF hi. I’m also one of the maintainers of this project, filling in some of the data requested:

  1. the following user has these issues for sure - 2bf74b91-22f2-46c4-b342-74ede104a7e4 . We can probably get more if needed.
  2. we have a post authentication trigger which adds/updates a custom:sign_in_at property, adding code below:
import AWS from "aws-sdk";

export const handler = async (event) => {
  console.log(event);
  const userSub = event.request?.userAttributes?.sub;
  if (!userSub) {
    throw new Error("No userSub found in event.request.UserAttributes");
  }

  const cognitoIdentity = new AWS.CognitoIdentityServiceProvider({
    accessKeyId: process.env.AWS_COGNITO_ACCESS,
    secretAccessKey: process.env.AWS_COGNITO_SECRET,
    region: process.env.AWS_COGNITO_REGION,
  });

  await cognitoIdentity
    .adminUpdateUserAttributes({
      UserAttributes: [
        {
          Name: "custom:sing_in_at",
          Value: new Date().toISOString(),
        },
      ],
      UserPoolId: process.env.AWS_COGNITO_USERPOOL_ID,
      Username: userSub,
    })
    .promise();

  return event;
};

edit: today we’re not relying too much on this extra attribute, it helped us with user migration some time ago - so if there’s a chance this will help the issue, we can just turn this trigger off - in fact, I’ll do it right away to collect some data on this

  1. did not see any. So far we haven’t tried logging in as this user (will probably need to contact them through support about changing their password to a temporary one), but I’ve copied over all of their user attributes except for sub and email into another account and could not reproduce the problem this way