Infinite loader in entity creation

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

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: -

Hello @Quentin_Somerville1,

Thanks for the report. :pray:

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 :grimacing:

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

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

"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"
  },

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,

Hi @dogan.ay

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

    "@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

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

When I click on “create”

After closing the toaster → Infinite loader

And also I have no error in the console

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 configuration defined on your field ?

Hi @dogan.ay
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

{
          "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

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.

1 Like

Hello @dogan.ay

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

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

Yes it’s fixed
Thanks @dogan.ay :slight_smile:

2 Likes