# Infinite loader in entity creation

**URL:** <https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383>\
**Category:** Help me!\
**Created:** [August 8, 2024, 1:21am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383 "2024-08-08T01:21:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 8, 2024, 1:21am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/1 "2024-08-08T01:21:57Z")

</div>

## Feature(s) impacted

I overrided the creation of a collection with the `overrideCreate` method. In this override I process some data validation. If data is wrong I use `UnprocessableError` from `@forestadmin/datasource-toolkit` to throw an error.  
In frontend when user gets the error he get an invinite loader on the “create” button so he can’t update the data and try again.

Here is some reproduciton code

```javascript
const overrideCreate: CreateOverrideHandler<
  Schema,
  'MyCollection'
> = async (context) => {
  const { data } = context;

  const { someColumn } = data[0];

  if (!someColumn) {
    throw new UnprocessableError('someColumn must be defined'); // This line triggers the infinite loader
  }
...

  
};

export default overrideCreate;

```

## Observed behavior

When I create an entity if user get a backend error after clicking on “create” there is an infinite loader

## Expected behavior

If user get an error the loader disappear and after changing the data he can retry to create the entity

## Failure Logs

## Context

- Project name: Roundtable
- Team name: -
- Environment name: All
- Agent technology: nodejs
- Agent (forest package) name & version: “@forestadmin/agent”: “^1.41.7”,
- Database type: postgres
- Recent changes made on your end if any: -

---

<div class="post-metadata">

**Author:** ![morganperre](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/morganperre/32/1296_2.png) [@morganperre](https://community.forestadmin.com/u/morganperre)\
**Post date:** [August 8, 2024, 6:55am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/2 "2024-08-08T06:55:56Z")

</div>

Hello @Quentin_Somerville1,

Thanks for the report. 🙏

I tried to reproduce your issue but I have the right behavior.

- I do receive the error from the agent and it is display in a toastr accordingly.
- I don’t have any infinite Create button loading 😬

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/d13dacf480c6ab16c31eccb2dddb853659e2df65.png)

Did you create the data in a simple level or is it nested data (related data) creation ?  
Did you use a recent version of `@forestadmin/agent` ? What are the packages versions and which packages do you have in your `package.json` ?

Thanks in advance for your information.

Kind regards,  
Morgan

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 9, 2024, 3:36am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/3 "2024-08-09T03:36:05Z")

</div>

Hello @morganperre

It’s indeed a nested relation. I have an entity A that have several children B  
It happens when I create a entity B From the “Related Data” section of entity A

About the version I updated it quite recently.  
The forest dependencies are

```javascript
"dependencies": {
    "@forestadmin-experimental/plugin-gcs": "^0.0.4",
    "@forestadmin/agent": "^1.41.7",
    "@forestadmin/datasource-customizer": "^1.45.6",
    "@forestadmin/datasource-sql": "^1.14.11",
    "@forestadmin/datasource-toolkit": "^1.34.4",
    "@forestadmin/plugin-flattener": "^1.1.1"
  },

```

---

<div class="post-metadata">

**Author:** ![anon7284711](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon7284711](https://community.forestadmin.com/u/anon7284711)\
**Post date:** [August 12, 2024, 2:43pm UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/4 "2024-08-12T14:43:21Z")

</div>

Hello @Quentin_Somerville1,

Just as @morganperre said, I also observe the correct behaviour.

The issue might come from the fact that you are defining `@forestadmin/datasource-customizer` and `@forestadmin/datasource-toolkit` dependencies. Those two are sub-dependencies of `@forestadmin/agent` and `@forestadmin/datasource-sql`. You may have conflicting versions in your `.lock` file.

Remove both of these definitions and try again, tell me if it works out for you.

Best regards,

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 14, 2024, 12:47am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/5 "2024-08-14T00:47:35Z")

</div>

Hi @anon7284711

I can’t remove these dependencies because I am using it directly in the code.  
But I updated a bit the version so I’m sure only one is installed and there are no conflict.  
Now I have

```javascript
    "@forestadmin/agent": "1.41.9",
    "@forestadmin/datasource-customizer": "1.46.1",
    "@forestadmin/datasource-sql": "1.14.11",
    "@forestadmin/datasource-toolkit": "1.34.4",
    "@forestadmin/plugin-flattener": "1.2.8",

```

And I checked in the `pnpm-lock.yaml` there are no duplicates of versions for `@forestadmin/datasource-toolkit` and `@forestadmin/datasource-customizer`

But I still get the inifinite loader

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 14, 2024, 12:52am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/6 "2024-08-14T00:52:50Z")

</div>

Also I tried to create an entity without the required fields. This seems to be a frontend check because no http call is triggered in the network.  
And I also have an inifinite loader

**Before**

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/68cebcf92acb07937c939b9f5847184847a586aa.jpeg)

**When I click on “create”**

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/e/e4c4285006d0b20d242817ba206fb9203f50c74d.png)

**After closing the toaster → Infinite loader**

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/5/51f19306390e85939f8654ee089083b40b11d743.png)

And also I have no error in the console

---

<div class="post-metadata">

**Author:** ![anon7284711](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon7284711](https://community.forestadmin.com/u/anon7284711)\
**Post date:** [August 14, 2024, 8:24am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/7 "2024-08-14T08:24:53Z")

</div>

If there are no calls to the agent, it most certainly is from the validations you have define on your schema.

I have tried to reproduce but I do not observe an infinite spinner, although I do get the same error message.

Could you share with me the [validation](https://docs.forestadmin.com/developer-guide-agents-nodejs/agent-customization/fields/validation) configuration defined on your field ?

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 28, 2024, 3:34am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/8 "2024-08-28T03:34:39Z")

</div>

Hi @anon7284711  
Yes for this purpose it’s the validations defines in the schema  
We didn’t add extra validation it’s only the generated validation that we have according to the database.  
In the schema it is generated as

```javascript
{
          "defaultValue": null,
          "enums": [],
          "field": "name",
          "integration": null,
          "inverseOf": null,
          "isFilterable": true,
          "isPrimaryKey": false,
          "isReadOnly": false,
          "isRequired": true,
          "isSortable": true,
          "isVirtual": false,
          "reference": null,
          "type": "String",
          "validations": [{"type": "is present", "message": "Field is required"}]
        }

```

But that’s normal that the form make the field required. The only thing wrong is the inifinte loader

---

<div class="post-metadata">

**Author:** ![anon7284711](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon7284711](https://community.forestadmin.com/u/anon7284711)\
**Post date:** [August 28, 2024, 1:21pm UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/9 "2024-08-28T13:21:08Z")

</div>

Hello @Quentin_Somerville1,

I was able to reproduce and released a fix.

You should be able to benefit from it by refreshing your frontend, tell me if it works for you.

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 29, 2024, 3:13am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/10 "2024-08-29T03:13:29Z")

</div>

Hello @anon7284711

I refreshed the page without cache but I still get the issue. Is there something else I must do to get the fix ?

---

<div class="post-metadata">

**Author:** ![anon7284711](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon7284711](https://community.forestadmin.com/u/anon7284711)\
**Post date:** [August 29, 2024, 9:28am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/11 "2024-08-29T09:28:36Z")

</div>

Could you try again, it seems like the issue was present at multiple locations. They should be all fixed. Sorry for the inconvenience.

---

<div class="post-metadata">

**Author:** ![Quentin\_Somerville1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/quentin_somerville1/32/7114_2.png) [@Quentin\_Somerville1](https://community.forestadmin.com/u/Quentin_Somerville1)\
**Post date:** [August 30, 2024, 4:30am UTC](https://community.forestadmin.com/t/infinite-loader-in-entity-creation/7383/12 "2024-08-30T04:30:01Z")

</div>

Yes it’s fixed  
Thanks @anon7284711 🙂
