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

Build error "Type instantiation is excessively deep and possibly infinite." #14057

Closed
3 tasks done
nam-truong-le opened this issue Dec 8, 2024 · 3 comments
Closed
3 tasks done
Assignees
Labels
GraphQL Related to GraphQL API issues

Comments

@nam-truong-le
Copy link

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

GraphQL API

Amplify Version

v6

Amplify Categories

api

Backend

Amplify Gen 2

Environment information

# Put output below this line
  System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M3
    Memory: 259.19 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.15.0 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 18.1.1
  npmPackages:
    @aws-amplify/adapter-nextjs: 1.2.30 => 1.2.30 
    @aws-amplify/backend: 1.8.0 => 1.8.0 
    @aws-amplify/backend-cli: 1.4.2 => 1.4.2 
    @aws-amplify/ui-react: 6.7.1 => 6.7.1 
    @emotion/react: 11.13.5 => 11.13.5 
    @emotion/styled: 11.13.5 => 11.13.5 
    @fontsource/roboto: 5.1.0 => 5.1.0 
    @mui/icons-material: 6.1.10 => 6.1.10 
    @mui/material: 6.1.10 => 6.1.10 
    @reduxjs/toolkit: 2.4.0 => 2.4.0 
    @types/lodash.compact: 3.0.9 => 3.0.9 
    @types/lodash.uniq: 4.5.9 => 4.5.9 
    @types/node: 20.17.9 => 20.17.9 
    @types/react: 18.3.14 => 18.3.14 
    @types/react-dom: 18.3.2 => 18.3.2 
    aws-amplify: 6.10.2 => 6.10.2 
    aws-cdk: 2.172.0 => 2.172.0 
    aws-cdk-lib: 2.172.0 => 2.172.0 
    constructs: 10.4.2 => 10.4.2 
    dayjs: 1.11.13 => 1.11.13 
    decimal.js: 10.4.3 => 10.4.3 
    env-cmd: 10.1.0 => 10.1.0 
    envinfo: 7.14.0 => 7.14.0 
    esbuild: 0.24.0 => 0.24.0 
    lodash.compact: 3.0.1 => 3.0.1 
    lodash.uniq: 4.5.0 => 4.5.0 
    next: 14.2.20 => 14.2.20 
    prettier: 3.4.2 => 3.4.2 
    react: ^18 => 18.3.1 
    react-dom: ^18 => 18.3.1 
    react-redux: 9.1.2 => 9.1.2 
    tsx: 4.19.2 => 4.19.2 
    typescript: 5.7.2 => 5.7.2 
    uuid: 11.0.3 => 11.0.3 
  npmGlobalPackages:
    corepack: 0.29.3
    node-gyp: 10.2.0
    npm: 10.8.2


Describe the bug

I use the same selection set for client.models.Foo.onUpdate and client.models.Foo.observeQuery, the observeQuery cannot be build because of this error "Type error: Type instantiation is excessively deep and possibly infinite."

Local dev is working fine.

Expected behavior

Project can be built.

Reproduction steps

  1. Create data models using hasMany, oneOf
  2. Use observeQuery
  3. Build the project

Code Snippet

  // this works
  useEffect(() => {
    const sub = client.models.Store.onUpdate({
      authMode: "userPool",
      selectionSet: storeAdminSelectionSet,
    }).subscribe({
      next: (item) => {
        dispatch(updateStore(item));
      },
    });

    return () => sub.unsubscribe();
  }, []);

  // here build error: "Type error: Type instantiation is excessively deep and possibly infinite."
  useEffect(() => {
    const sub = client.models.Store.observeQuery({
      authMode: "userPool",
      selectionSet: storeAdminSelectionSet,
    }).subscribe({
      next: ({ items }: { items: StoreAdmin[] }) => {
        dispatch(setStores([...items]));
      },
    });

    return () => sub.unsubscribe();
  }, []);

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 Dec 8, 2024
@nam-truong-le
Copy link
Author

If I don't provide a selectionSet, then there is no build error.

@chrisbonifacio chrisbonifacio self-assigned this Dec 9, 2024
@chrisbonifacio chrisbonifacio added GraphQL Related to GraphQL API issues pending-community-response Issue is pending a response from the author or community. and removed pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Dec 9, 2024
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Dec 11, 2024

Hi @nam-truong-le 👋 can you please share the schema for all of the affected models that reproduce this issue?

When you say this is a "build error" and "local dev is working fine" can you clarify when or where exactly the error is occurring? Is it during a local build of the app (ex. npm run build) or is it during deployment after merging changes to your branch?

Does this error not occur in local dev at all? Such as when observeQuery is called at runtime?

Also please provide any build error logs if available.

@chrisbonifacio
Copy link
Member

Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.

Thank you!

@chrisbonifacio chrisbonifacio closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@github-actions github-actions bot removed the pending-community-response Issue is pending a response from the author or community. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GraphQL Related to GraphQL API issues
Projects
None yet
Development

No branches or pull requests

2 participants