Amplify-cli: Amplify Mock running in a loop (constantly detecting changes)

Created on 14 Nov 2019  Â·  10Comments  Â·  Source: aws-amplify/amplify-cli

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

Describe the bug
Amplify mock is constantly detecting changes when I add one single change to my schema. GraphQL Schema change detected. Reloading.... This regenerates all resolvers + API.service.ts which triggers Angular watch in a loop.

Amplify CLI Version
3.17.0

To Reproduce

Creating table CustomerTable locally
Creating table PersonTable locally
Creating table ProjectTable locally
Creating table CaseTable locally
Creating table CategoryTable locally
Creating table EmailLogTable locally
Creating table SearchLogTable locally
Creating table TemplateTable locally
Creating table WikiTable locally
Creating table WikiPageTable locally
Creating table MailboxTable locally
Creating table AreaTable locally
Creating table MilestoneTable locally
Creating table WorkflowTable locally
Creating table ProjectGroupTable locally
Creating table TokenTable locally
Creating table UserGroupTable locally
Creating table DiscussGroupTable locally
Creating table DiscussTopicTable locally
Creating table FilterGroupTable locally
Running GraphQL codegen
√ Generated GraphQL operations successfully and saved at src\graphql
√ Code generated successfully and saved in file src\app\API.service.ts
GraphQL Schema change detected. Reloading...

The following types do not have '@auth' enabled. Consider using @auth with @model
         - Customer
         - Person
         - Project
         - Case
         - Category
         - EmailLog
         - SearchLog
         - Template
         - Wiki
         - WikiPage
         - Mailbox
         - Area
         - Milestone
         - Workflow
         - ProjectGroup
         - Token
         - UserGroup
         - DiscussGroup
         - DiscussTopic
         - FilterGroup
Learn more about @auth here: https://aws-amplify.github.io/docs/cli-toolchain/graphql#auth

Expected behavior
The mock should stop detecting any changes, if there are no more changes.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Node Version: 10.15.3

Additional context
This doesn't happen if I restore my environment, so basically running amplify env pull --restore and after starting the mock it works fine, but once one change is added it enters into a loop of detecting changes.
If I push my change and restore the environment again, it works. Adding a new property on a type for example again triggers the change loop. So basically whatever is generated after 1st change triggers constantly a change detection like it would compare it against cloud ....

bug mock pending-close-response-required windows

Most helpful comment

@kaustavghosh06 I am seeing the same issue as @xoadrian. Saw it on v3.17, still seeing it on v4.12.

The issue is intermittant and sometimes can be resolved by deleting the mock data folder or running plugin scan, but infruiating once it gets going.

On Windows 10, Node 10.16.1. Happens on my desktop and laptop dev machines, both intermittantly.

All 10 comments

@xoadrian Can you install the latest version of the CLI and see if this issue still exists?

@kaustavghosh06 I am seeing the same issue as @xoadrian. Saw it on v3.17, still seeing it on v4.12.

The issue is intermittant and sometimes can be resolved by deleting the mock data folder or running plugin scan, but infruiating once it gets going.

On Windows 10, Node 10.16.1. Happens on my desktop and laptop dev machines, both intermittantly.

Facing the same issue, running amplify mock keeps on continuously detecting changes and does not run.

Experiencing this as well. As a workaround you can:

cp -r amplify/backend/api/my-project/build/resolvers/* amplify/backend/api/my-project/resolvers/

And then run amplify mock api again.

I experienced this today, and it resolved when I ran the fix by @Jrb1x

@kaustavghosh06 I’m also dealing with the same problem. I tried the workarround by @Jrb1x but whenever i do a change in my schema.graphql its goes in a infinite loop. Its frustating. Dont know the solution

I tried to isolate the problem. I have come to the conclusion that the problem happens when you have 13 o more types @model declared in your schema.graphql file. But if you have 12 or less types, all is OK.

Amplify CLI Version
4.18.1

Desktop:

  • OS: Windows 10

  • Node Version: 12.16.2

Take a look at this schema:

type Test1 @model {
    id: ID!
}
type Test2 @model {
    id: ID!
}
type Test3 @model {
    id: ID!
}
type Test4 @model {
    id: ID!
}
type Test5 @model {
    id: ID!
}
type Test6 @model {
    id: ID!
}
type Test7 @model {
    id: ID!
}
type Test8 @model {
    id: ID!
}
type Test9 @model {
    id: ID!
}
type Test10 @model {
    id: ID!
}
type Test11 @model {
    id: ID!
}
type Test12 @model {
    id: ID!
}
type Test13 @model {
    id: ID!
}

Steps to reproduce the error:

  1. Delete mock-data folder
  2. run amplify mock api in the command line

Also sometimes during the infinite loop it throws an error like this:
Error: ENOENT: no such file or directory, lstat 'C:\project_folder\amplify\backend\api\project\resolvers\Mutation.createTest11.req.vtl'

Take a look at the attached log file where you can see how is goes the execution of the loop.
log.txt

Maybe is related in some way with this issue #2170

It is worthwhile to mention that I have reinstaled @aws-amplify/cli and initiated a new project with amplify init(with default values) and the same problems occurs.

Thank you.

The fix has been released in Amplify CLI v 4.21.0

we are still seeing this issue with Amplify CLI v 4.21.2

we are still seeing this issue with Amplify CLI v 4.21.2

@gaochenyue How many models do you have in your schema? Could you share a test project where this could be reproduced

This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings