amplify-js: aws-crypto lib: Cannot read properties of undefined (reading 'byteLength')

Before opening, please confirm:

JavaScript Framework

Angular

Amplify APIs

REST API

Amplify Categories

api

Environment information

# Put output below this line
  System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 4.81 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.3 - ~/.nvm/versions/node/v14.15.3/bin/node
    npm: 7.19.1 - ~/.nvm/versions/node/v14.15.3/bin/npm
    Watchman: 2021.10.04.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 96.0.4664.55
    Edge: 95.0.1020.53
    Firefox: 94.0.1
    Safari: 14.1.2
  npmPackages:
    @angular-builders/custom-webpack: ^12.1.0 => 12.1.0 
    @angular-devkit/build-angular: ^12.1.1 => 12.1.1 
    @angular-eslint/builder: ^12.0.0 => 12.2.0 
    @angular-eslint/eslint-plugin: ^12.0.0 => 12.2.0 
    @angular-eslint/eslint-plugin-template: ^12.0.0 => 12.2.0 
    @angular-eslint/schematics: 12.2.0 => 12.2.0 
    @angular-eslint/template-parser: ^12.0.0 => 12.2.0 
    @angular/animations: ~12.1.1 => 12.1.1 (11.0.3)
    @angular/animations/browser:  undefined ()
    @angular/animations/browser/testing:  undefined ()
    @angular/cdk: ^12.1.1 => 12.1.1 
    @angular/cdk/a11y:  undefined ()
    @angular/cdk/accordion:  undefined ()
    @angular/cdk/bidi:  undefined ()
    @angular/cdk/clipboard:  undefined ()
    @angular/cdk/coercion:  undefined ()
    @angular/cdk/collections:  undefined ()
    @angular/cdk/drag-drop:  undefined ()
    @angular/cdk/keycodes:  undefined ()
    @angular/cdk/layout:  undefined ()
    @angular/cdk/observers:  undefined ()
    @angular/cdk/overlay:  undefined ()
    @angular/cdk/platform:  undefined ()
    @angular/cdk/portal:  undefined ()
    @angular/cdk/scrolling:  undefined ()
    @angular/cdk/stepper:  undefined ()
    @angular/cdk/table:  undefined ()
    @angular/cdk/testing:  undefined ()
    @angular/cdk/testing/protractor:  undefined ()
    @angular/cdk/testing/selenium-webdriver:  undefined ()
    @angular/cdk/testing/testbed:  undefined ()
    @angular/cdk/text-field:  undefined ()
    @angular/cdk/tree:  undefined ()
    @angular/cli: ~12.1.1 => 12.1.1 
    @angular/common: ~12.1.1 => 12.1.1 (11.0.3)
    @angular/common/http:  undefined ()
    @angular/common/http/testing:  undefined ()
    @angular/common/testing:  undefined ()
    @angular/common/upgrade:  undefined ()
    @angular/compiler: ~12.1.1 => 12.1.1 
    @angular/compiler-cli: ^12.1.1 => 12.1.1 
    @angular/compiler/testing:  undefined ()
    @angular/core: ~12.1.1 => 12.1.1 (11.0.3)
    @angular/core/testing:  undefined ()
    @angular/elements: ~12.1.1 => 12.1.1 
    @angular/forms: ~12.1.1 => 12.1.1 
    @angular/material: ^12.1.1 => 12.1.1 
    @angular/material/autocomplete:  undefined ()
    @angular/material/autocomplete/testing:  undefined ()
    @angular/material/badge:  undefined ()
    @angular/material/badge/testing:  undefined ()
    @angular/material/bottom-sheet:  undefined ()
    @angular/material/bottom-sheet/testing:  undefined ()
    @angular/material/button:  undefined ()
    @angular/material/button-toggle:  undefined ()
    @angular/material/button-toggle/testing:  undefined ()
    @angular/material/button/testing:  undefined ()
    @angular/material/card:  undefined ()
    @angular/material/card/testing:  undefined ()
    @angular/material/checkbox:  undefined ()
    @angular/material/checkbox/testing:  undefined ()
    @angular/material/chips:  undefined ()
    @angular/material/chips/testing:  undefined ()
    @angular/material/core:  undefined ()
    @angular/material/core/testing:  undefined ()
    @angular/material/datepicker:  undefined ()
    @angular/material/datepicker/testing:  undefined ()
    @angular/material/dialog:  undefined ()
    @angular/material/dialog/testing:  undefined ()
    @angular/material/divider:  undefined ()
    @angular/material/divider/testing:  undefined ()
    @angular/material/expansion:  undefined ()
    @angular/material/expansion/testing:  undefined ()
    @angular/material/form-field:  undefined ()
    @angular/material/form-field/testing:  undefined ()
    @angular/material/form-field/testing/control:  undefined ()
    @angular/material/grid-list:  undefined ()
    @angular/material/grid-list/testing:  undefined ()
    @angular/material/icon:  undefined ()
    @angular/material/icon/testing:  undefined ()
    @angular/material/input:  undefined ()
    @angular/material/input/testing:  undefined ()
    @angular/material/list:  undefined ()
    @angular/material/list/testing:  undefined ()
    @angular/material/menu:  undefined ()
    @angular/material/menu/testing:  undefined ()
    @angular/material/paginator:  undefined ()
    @angular/material/paginator/testing:  undefined ()
    @angular/material/progress-bar:  undefined ()
    @angular/material/progress-bar/testing:  undefined ()
    @angular/material/progress-spinner:  undefined ()
    @angular/material/progress-spinner/testing:  undefined ()
    @angular/material/radio:  undefined ()
    @angular/material/radio/testing:  undefined ()
    @angular/material/select:  undefined ()
    @angular/material/select/testing:  undefined ()
    @angular/material/sidenav:  undefined ()
    @angular/material/sidenav/testing:  undefined ()
    @angular/material/slide-toggle:  undefined ()
    @angular/material/slide-toggle/testing:  undefined ()
    @angular/material/slider:  undefined ()
    @angular/material/slider/testing:  undefined ()
    @angular/material/snack-bar:  undefined ()
    @angular/material/snack-bar/testing:  undefined ()
    @angular/material/sort:  undefined ()
    @angular/material/sort/testing:  undefined ()
    @angular/material/stepper:  undefined ()
    @angular/material/stepper/testing:  undefined ()
    @angular/material/table:  undefined ()
    @angular/material/table/testing:  undefined ()
    @angular/material/tabs:  undefined ()
    @angular/material/tabs/testing:  undefined ()
    @angular/material/toolbar:  undefined ()
    @angular/material/toolbar/testing:  undefined ()
    @angular/material/tooltip:  undefined ()
    @angular/material/tooltip/testing:  undefined ()
    @angular/material/tree:  undefined ()
    @angular/material/tree/testing:  undefined ()
    @angular/platform-browser: ~12.1.1 => 12.1.1 (11.0.3)
    @angular/platform-browser-dynamic: ~12.1.1 => 12.1.1 
    @angular/platform-browser-dynamic/testing:  undefined ()
    @angular/platform-browser/animations:  undefined ()
    @angular/platform-browser/testing:  undefined ()
    @angular/router: ~12.1.1 => 12.1.1 (11.0.3)
    @angular/router/testing:  undefined ()
    @angular/router/upgrade:  undefined ()
    @gammastream/scully-plugin-sitemap: ^1.0.7 => 1.0.7 
    @ng-select/ng-option-highlight: 0.0.6 => 0.0.6 
    @ng-select/ng-select: ^7.1.0 => 7.1.0 
    @ngneat/until-destroy: ^8.0.3 => 8.0.4 
    @scullyio/init: ^1.1.4 => 1.1.4 
    @scullyio/ng-lib: ^1.1.1 => 1.1.1 
    @scullyio/scully: ^1.1.1 => 1.1.1 
    @scullyio/scully-plugin-critical-css: 0.1.1 => 0.1.1 
    @sentry/angular: ^6.13.2 => 6.13.2 
    @sentry/cli: ^1.66.0 => 1.66.0 
    @sentry/tracing: ^6.13.2 => 6.13.2 (5.30.0)
    @types/applepayjs: ^3.0.1 => 3.0.1 
    @types/cheerio: ^0.22.23 => 0.22.29 
    @types/imagemin: ^7.0.0 => 7.0.0 
    @types/imagemin-gifsicle: ^7.0.0 => 7.0.0 
    @types/imagemin-mozjpeg: ^8.0.0 => 8.0.0 
    @types/imagemin-optipng: ^5.2.0 => 5.2.0 
    @types/imagemin-svgo: ^8.0.0 => 8.0.1 
    @types/jasmine: ~3.6.0 => 3.6.11 
    @types/jasminewd2: ~2.0.3 => 2.0.9 
    @types/js-beautify: ^1.13.1 => 1.13.1 
    @types/jsdom: ^16.2.5 => 16.2.12 
    @types/marked: ^1.2.0 => 1.2.2 
    @types/node: 14.0.4 => 14.0.4 
    @types/node-zendesk: ^1.4.0 => 1.4.0 
    @types/yamljs: ^0.2.31 => 0.2.31 
    @typescript-eslint/eslint-plugin: 4.23.0 => 4.23.0 
    @typescript-eslint/parser: 4.23.0 => 4.23.0 (3.10.1)
    angular-cc-library: ^2.1.2 => 2.1.2 
    array-flat-polyfill: ^1.0.1 => 1.0.1 
    aws-amplify: ^4.3.4 => 4.3.4 
    axios: ^0.21.1 => 0.21.4 
    body-parser: ^1.19.0 => 1.19.0 
    cheerio: ^1.0.0-rc.3 => 1.0.0-rc.10 (0.22.0)
    commander: ^2.20.3 => 2.20.3 (4.1.1, 7.2.0, 2.13.0, 6.2.1)
    document-register-element: ^1.7.2 => 1.14.10 
    dotenv-webpack: ^7.0.3 => 7.0.3 
    eslint: ^7.26.0 => 7.30.0 
    eslint-config-prettier: ^8.3.0 => 8.3.0 
    eslint-plugin-import: latest => 2.23.4 
    eslint-plugin-jsdoc: latest => 35.4.1 
    eslint-plugin-prefer-arrow: latest => 1.2.3 
    eslint-plugin-react: latest => 7.24.0 
    example-typescript:  1.0.0 
    fast-xml-parser: ^3.17.6 => 3.19.0 
    folder-hash: ^3.3.0 => 3.3.3 
    fractional: ^1.0.0 => 1.0.0 
    front-matter: ^4.0.2 => 4.0.2 
    fs-extra: ^9.0.0 => 9.1.0 (8.1.0, 1.0.0)
    image-size: ^0.9.7 => 0.9.7 (0.5.5, 0.6.3)
    imagemin: ^7.0.1 => 7.0.1 
    imagemin-gifsicle: ^7.0.0 => 7.0.0 
    imagemin-mozjpeg: ^9.0.0 => 9.0.0 
    imagemin-optipng: ^8.0.0 => 8.0.0 
    imagemin-svgo: ^8.0.0 => 8.0.0 
    jasmine-core: ~3.6.0 => 3.6.0 (2.8.0)
    jasmine-spec-reporter: ~5.0.0 => 5.0.2 
    js-beautify: ^1.13.0 => 1.14.0 
    js-yaml-loader: ^1.2.2 => 1.2.2 
    json_encode: ^0.1.0 => 0.1.0 
    karma: ~6.3.4 => 6.3.4 
    karma-chrome-launcher: ~3.1.0 => 3.1.0 
    karma-coverage-istanbul-reporter: ~3.0.2 => 3.0.3 
    karma-jasmine: ~4.0.0 => 4.0.1 
    karma-jasmine-html-reporter: ^1.5.0 => 1.6.0 
    lib:  0.0.1 
    libphonenumber-js: ^1.8.3 => 1.9.20 
    libphonenumber-js-core:  1.0.0 
    libphonenumber-js-max:  1.0.0 
    libphonenumber-js-min:  1.0.0 
    libphonenumber-js-mobile:  1.0.0 
    lodash-es: ^4.17.15 => 4.17.21 
    lodash.merge: ^4.6.2 => 4.6.2 
    lodash.snakecase: ^4.1.1 => 4.1.1 
    marked: ^1.2.5 => 1.2.9 (2.1.3)
    ng2-pdf-viewer: ^6.3.2 => 6.4.1 
    ngx-build-plus: ^12.0.1 => 12.0.1 
    ngx-webcam: ^0.3.2 => 0.3.2 
    node-example:  1.0.0 
    object.fromentries: ^2.0.2 => 2.0.4 
    prettier-eslint: ^12.0.0 => 12.0.0 
    prompt-sync: ^4.2.0 => 4.2.0 
    protractor: ~7.0.0 => 7.0.0 
    protractor-example:  1.0.0 
    rxjs: ~6.6.6 => 6.6.7 (6.4.0, 6.5.4)
    rxjs/ajax:  undefined ()
    rxjs/fetch:  undefined ()
    rxjs/internal-compatibility:  undefined ()
    rxjs/operators:  undefined ()
    rxjs/testing:  undefined ()
    rxjs/webSocket:  undefined ()
    s-ago: ^2.2.0 => 2.2.0 
    scully-plugin-minify-html: ^6.0.0 => 6.0.0 
    stripe: ^8.169.0 => 8.169.0 
    svg-inline-loader: ^0.8.2 => 0.8.2 
    tmp: ^0.1.0 => 0.1.0 (0.2.1, 0.0.33, 0.0.30)
    ts-node: ~8.3.0 => 8.3.0 (10.0.0)
    tslib: ^2.0.0 => 2.3.0 (1.14.1)
    typescript: ~4.3.5 => 4.3.5 (4.3.4, 3.9.10)
    typescript-example:  1.0.0 
    uuid: ^8.3.1 => 8.3.2 (3.4.0)
    webpack-bundle-analyzer: ^4.4.2 => 4.4.2 
    which: ^2.0.2 => 2.0.2 (1.3.1)
    xmlbuilder: ^15.1.1 => 15.1.1 (9.0.7, 11.0.1)
    yamljs: ^0.3.0 => 0.3.0 
    zone-mix:  undefined ()
    zone-node:  undefined ()
    zone-testing:  undefined ()
    zone.js: ~0.11.4 => 0.11.4 (0.10.3)
    zone.js/async-test:  undefined ()
    zone.js/async-test.min:  undefined ()
    zone.js/fake-async-test:  undefined ()
    zone.js/fake-async-test.min:  undefined ()
    zone.js/jasmine-patch:  undefined ()
    zone.js/jasmine-patch.min:  undefined ()
    zone.js/long-stack-trace-zone:  undefined ()
    zone.js/long-stack-trace-zone.min:  undefined ()
    zone.js/mocha-patch:  undefined ()
    zone.js/mocha-patch.min:  undefined ()
    zone.js/proxy:  undefined ()
    zone.js/proxy.min:  undefined ()
    zone.js/sync-test:  undefined ()
    zone.js/sync-test.min:  undefined ()
    zone.js/task-tracking:  undefined ()
    zone.js/task-tracking.min:  undefined ()
    zone.js/webapis-media-query:  undefined ()
    zone.js/webapis-media-query.min:  undefined ()
    zone.js/webapis-notification:  undefined ()
    zone.js/webapis-notification.min:  undefined ()
    zone.js/webapis-rtc-peer-connection:  undefined ()
    zone.js/webapis-rtc-peer-connection.min:  undefined ()
    zone.js/webapis-shadydom:  undefined ()
    zone.js/webapis-shadydom.min:  undefined ()
    zone.js/wtf:  undefined ()
    zone.js/wtf.min:  undefined ()
    zone.js/zone-bluebird:  undefined ()
    zone.js/zone-bluebird.min:  undefined ()
    zone.js/zone-error:  undefined ()
    zone.js/zone-error.min:  undefined ()
    zone.js/zone-legacy:  undefined ()
    zone.js/zone-legacy.min:  undefined ()
    zone.js/zone-patch-canvas:  undefined ()
    zone.js/zone-patch-canvas.min:  undefined ()
    zone.js/zone-patch-cordova:  undefined ()
    zone.js/zone-patch-cordova.min:  undefined ()
    zone.js/zone-patch-electron:  undefined ()
    zone.js/zone-patch-electron.min:  undefined ()
    zone.js/zone-patch-fetch:  undefined ()
    zone.js/zone-patch-fetch.min:  undefined ()
    zone.js/zone-patch-jsonp:  undefined ()
    zone.js/zone-patch-jsonp.min:  undefined ()
    zone.js/zone-patch-message-port:  undefined ()
    zone.js/zone-patch-message-port.min:  undefined ()
    zone.js/zone-patch-promise-test:  undefined ()
    zone.js/zone-patch-promise-test.min:  undefined ()
    zone.js/zone-patch-resize-observer:  undefined ()
    zone.js/zone-patch-resize-observer.min:  undefined ()
    zone.js/zone-patch-rxjs:  undefined ()
    zone.js/zone-patch-rxjs-fake-async:  undefined ()
    zone.js/zone-patch-rxjs-fake-async.min:  undefined ()
    zone.js/zone-patch-rxjs.min:  undefined ()
    zone.js/zone-patch-socket-io:  undefined ()
    zone.js/zone-patch-socket-io.min:  undefined ()
    zone.js/zone-patch-user-media:  undefined ()
    zone.js/zone-patch-user-media.min:  undefined ()
  npmGlobalPackages:
    @angular/cli: 12.1.1
    @aws-amplify/cli: 7.4.4
    firebase-tools: 9.8.0
    local-web-server: 4.2.1
    npm: 7.19.1

Describe the bug

Sentry in my web app is reporting the following error on a few Android devices: “Uncaught (in promise): TypeError: Cannot read properties of undefined (reading ‘byteLength’) TypeError: Cannot read properties of undefined (reading ‘byteLength’)”

It seems this error is thrown when the device has network issues - a bunch of get rest api and cognito requests return http status 0 sentry shows (no response).

It seems isEmptyData in the aws-crypto lib should handle the case where data is undefined and return true for that as well.

exports.isEmptyData = void 0;
function isEmptyData(data) {
    if (typeof data === "string") {
        return data.length === 0;
    }

    return data.byteLength === 0;
}

Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'byteLength') TypeError: Cannot read prop… 2021-11-21 16-19-54

Expected behavior

Code shouldn’t fail if there is network issue.

Reproduction steps

Unknown, I just see the error in Sentry (3 users so far), and they are all running Android.

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 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

Sorry yeah no more assistance needed here. We were attempting to read a file from s3 while the user’s token was expired.

On Fri, Oct 6, 2023, 5:33 PM Dan Kiuna @.***> wrote:

Hi @TrekSoft https://github.com/TrekSoft - let me know if you still need assistance with this issue.

— Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-js/issues/9265#issuecomment-1751426974, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZTBRUFSDPAH43RUBHLATX6B2LXAVCNFSM5IPWKVHKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZVGE2DENRZG42A . You are receiving this because you were mentioned.Message ID: @.***>

we are having the same issue.

Related to #11251

Amplify has a Slack channel? I didn’t know that. I prefer Slack but I’m on the Discord Amplify channel too - hisham#6667 is my username.