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

postgrest-provider not called any more for an update after the ReactAdmin 4 → 5 upgrade #10388

Closed
COil opened this issue Nov 27, 2024 · 3 comments

Comments

@COil
Copy link

COil commented Nov 27, 2024

What you were expecting:

  • When clicking on the "save" button of an edit page, the update() method of the provider should be called

What happened instead:

  • The update method of the provider is not called anymore , but we have the notification "element updated"

Steps to reproduce:

  • Go to the edit page of an entity, modifiy a field and click "save"

Related code:

We have added some log to the provider :

// ra-data-providers/postgrest-provider/index.ts

...

const loggingDataProvider: DataProvider = new Proxy(dataProvider, {
  get(target, prop) {
    return async (...args: object[]) => {
      console.log(`DataProvider method called: ${String(prop)}`, args);
      return target[prop as keyof DataProvider]?.(...args);
    };
  },
});

export default loggingDataProvider;

When we use the create form we have, the following output:

DataProvider method called: create  Array [ "entity", {…} ]
DataProvider method called: getOne Array [ "entity", {…} ]

And we can see the POST query in the network panel. The record is created.

But when on an edit page, we don't have any log for the provider, and we don't see any PATCH query sent to the backend.
What is weird is that we have the notifcation "Element updated" as if all was successful.

If we manually add an handler for the submit :

  const handleSubmit = (data: object) => {
    if (!record) throw new Error('RecordContext needed?');
    console.log('Form data submitted:', data);
    if (save) 
      update('articles', { id: record.id, data, previousData: record });{
      save(data)
        .then(() => console.log('Save successful')        )
        .catch((error: Error) => console.error('Save failed:', error));
    }
  };

  return (
    <MpContextProvider>
      <FormSidebarProvider formSidebarWidth={240}>
        <Form className={className} onSubmit={handleSubmit}>

Then is update is done and we can see the PATCH query.

Other information:

Environment

  • React-admin version: 5.3.3
  • Last version that did not exhibit the issue (if applicable): 4
  • React version: 18.3.1
  • Browser: all
  • Stack trace (in case of a JS error): No error.

We don't have a minimal reproducer for now. But where to look to debug this issue?

@slax57
Copy link
Contributor

slax57 commented Nov 27, 2024

Hi, and thanks for your question.
As explained in the react-admin contributing guide, we use the GitHub issues for bugs and feature requests only.

For support question ("How To", usage advice, or troubleshooting your own code), you have three options:

  • Community support: Ask your question on StackOverFlow. This makes your question easy to find by the developer community. StackOverFlow has great SEO, gamification, voting, and reputation system.
  • Community support: Ask your question on Discord. Some react-admin users and contributors might have time to answer your questions.
  • Professional support: If you're a React-Admin Enterprise Edition subscriber, you have unlimited access to the Professional Support service. This service guarantees that you'll get an answer shortly.
    If your problem is urgent, please consider subscribing to the Enterprise Edition, starting at 125€. It's a good way to contribute to the sustainability of react-admin.

So I'm closing this issue, and inviting you to ask your question in one of the support channels above.

@slax57 slax57 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
@COil
Copy link
Author

COil commented Dec 11, 2024

For other people how would access this issue. We fixed the problem by applying this patch:

-<EditBase>
+<EditBase mutationMode="pessimistic">

Related links:

@COil
Copy link
Author

COil commented Jan 10, 2025

Finally, the root cause was our custom notification component:

    <Admin
      ...     
      notification={NotificationSnackbar}>
      <Resource name="resource" {...resource} />
    </Admin>

The bug disappears when removing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants