4

We see that as soon as we call a 'delete' operation on the data provider, that react-admin pushes a CRUD_GET_ONE action onto the optimisticCalls array in usedataProvider.

Then after the server response on the delete operation, this is replayed and a getOne request is issued for the meanwhile deleted record. This causes a rejected promise from the data provider (since the object is not found) which shows as an 'element not found' popup in react-admin UI.

We see this both with undoable set to true or false, and with a redirect=list (the pop-up shows after redirection to list page upon delete)

Why is there a CRUD_GET_ONE action dispatched upon pressing <DeleteButton> that gets buffered and executed after the server has deleted the object? How can we avoid the issue?

Note this comment in useDataProvider.ts which explains why getOne gets executed after server response, but why is the action dispatched in the first place?

// in optimistic mode, all fetch calls are stacked, to be
// executed once the dataProvider leaves optimistic mode.
// In the meantime, the admin uses data from the store.
Bart007
  • 111
  • 6
  • Is this related ? https://github.com/marmelab/react-admin/issues/5541 – Striped Nov 17 '20 at 18:53
  • Yes, I am bayareacoder on GitHub. I started writing this as a stack overflow question then realized it's probably a bug in react-admin so filed on GitHub. The `getOne` is called because the refresh happens too early, still on the Edit page, before redirection. – Bart007 Nov 18 '20 at 20:02
  • You did good to ask on SO, the react-admin team asks the users to do so. I think they are currently investingating on this bug. Try to provide them a minimal reproducing example and watch the related issue on Github to have fresh updates on it. We are multiple users to face it, me included. – Striped Nov 18 '20 at 20:22
  • Ah..good I'm not the only one to face it. As in my Github post, I'm not having time to look into it more until after ~Dec10, after our product release. For now I use the workaround with a custom delete button that includes the `onSuccess` handler with the delayed refresh and that seems to work so far. We also won't do the runtime type checking in production to make data provider responses faster, so if we don't see it during dev, we should probably be ok in production. – Bart007 Nov 18 '20 at 21:12
  • Same workaround here :) I follow the issue on Github and I will try to help if I could going deeper on it time to time. Take care. – Striped Nov 19 '20 at 07:20

0 Answers0