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

Amplify[ADD_OAUTH_LISTENER] is not a function in the Browser #14036

Closed
3 tasks done
lloydwatkin opened this issue Nov 25, 2024 · 4 comments
Closed
3 tasks done

Amplify[ADD_OAUTH_LISTENER] is not a function in the Browser #14036

lloydwatkin opened this issue Nov 25, 2024 · 4 comments
Labels
Build Related to build issues Events Related to AppSync Events Gen 2 Issues related to Gen 2 Amplify projects GraphQL Related to GraphQL API issues pending-maintainer-response Issue is pending a response from the Amplify team.

Comments

@lloydwatkin
Copy link

Before opening, please confirm:

JavaScript Framework

Not applicable

Amplify APIs

Not applicable

Amplify Version

v6

Amplify Categories

auth

Backend

Amplify Gen 2

Environment information

lloyd@macmini appsync-event % npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
Need to install the following packages:
envinfo@7.14.0
Ok to proceed? (y) y

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 592.34 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.19.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
    Watchman: 2024.11.11.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 17.6
  npmPackages:
    @pulumi/aws: 6.13.3 => v6.13.3 
    @pulumi/pulumi: * => 3.140.0 
    aws-amplify: ^6.9.0 => 6.9.0 
    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 ()
    buffer: ^6.0.3 => 6.0.3 (4.9.2)
    parcel: ^2.13.1 => 2.13.1 
    process: ^0.11.10 => 0.11.10 
  npmGlobalPackages:
    corepack: 0.22.0
    detox: 20.25.5
    http-server: 14.1.1
    jest: 29.7.0
    npm: 10.2.4
    pulumi: 0.0.1
    react-native-cli: 2.0.1
    swagger-merger: 1.5.4
    yarn: 1.22.22

Describe the bug

Instantiating Amplify in the browser (latest Chrome) leads to error:

Screenshot 2024-11-25 at 09 59 11

Uncaught TypeError: e[U] is not a function
    at enableOAuthListener.ts:11:17
(anonymous) @ enableOAuthListener.ts:11Understand this errorAI

This is my entire code base:

import { Amplify } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/+esm'
import { events } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/data/+esm'

 // Initialize AWS Amplify
 const initializeAmplify = (apiKey) => {
          
    Amplify.configure({
        "API": {
            "Events": {
            "endpoint": "https://REDACTED.appsync-api.eu-west-1.amazonaws.com/event",
            "region": "eu-west-1",
            "defaultAuthMode": "lambda",
            "apiKey": "12345"
            }
        }
    })
}

Expected behavior

Loads ok.

I'm trying to use the Events API

Reproduction steps

Included above

Code Snippet

import { Amplify } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/+esm'
import { events } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/data/+esm'

 // Initialize AWS Amplify
 const initializeAmplify = (apiKey) => {
          
    Amplify.configure({
        "API": {
            "Events": {
            "endpoint": "https://REDACTED.appsync-api.eu-west-1.amazonaws.com/event",
            "region": "eu-west-1",
            "defaultAuthMode": "lambda",
            "apiKey": "12345"
            }
        }
    })
}

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

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Nov 25, 2024
@chrisbonifacio chrisbonifacio added AppSync Related to AppSync issues Gen 2 Issues related to Gen 2 Amplify projects Events Related to AppSync Events and removed AppSync Related to AppSync issues labels Nov 25, 2024
@HuiSF
Copy link
Member

HuiSF commented Nov 25, 2024

Hi @lloydwatkin thanks for opening this issue. Could you explain what are these import paths?

import { Amplify } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/+esm'
import { events } from 'https://cdn.jsdelivr.net/npm/aws-amplify@6.9.0/data/+esm'

As far as I know, Amplify JS v6 doesn't support use as CDN hosted JS bundles.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 25, 2024
@lloydwatkin
Copy link
Author

@HuiSF linked from https://www.jsdelivr.com/package/npm/aws-amplify

It seems to mostly work fine up until the above error. The files are compiled from parcel for the browser which is able to pull down the libraries and build.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 25, 2024
@HuiSF
Copy link
Member

HuiSF commented Nov 25, 2024

Hi @lloydwatkin thanks for the explanation. We've not tested Amplify JS library with CDN hosted bundles. We recommend you to use a npm package manager to install the Amplify dependencies into your project.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 25, 2024
@HuiSF HuiSF added Build Related to build issues and removed pending-triage Issue is pending triage labels Nov 26, 2024
@cwomack cwomack added the GraphQL Related to GraphQL API issues label Nov 26, 2024
@lloydwatkin
Copy link
Author

@HuiSF thanks, I've switched to compiling the Javascript and have hit another issue. I'll raise a new bug that.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending a response from the Amplify team. label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Related to build issues Events Related to AppSync Events Gen 2 Issues related to Gen 2 Amplify projects GraphQL Related to GraphQL API issues pending-maintainer-response Issue is pending a response from the Amplify team.
Projects
None yet
Development

No branches or pull requests

4 participants