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

[Bug]: The ReadData method is executed once when the datagrid component throws an exception #5566

Open
He-Wu opened this issue Jun 13, 2024 · 2 comments
Assignees
Labels
Area: DataGrid Status: Repro Missing Type: Possible Bug Needs to investigate more to see if it's an actual bug.

Comments

@He-Wu
Copy link

He-Wu commented Jun 13, 2024

Blazorise Version

1.2.3

What Blazorise provider are you running on?

Bootstrap5

Link to minimal reproduction or a simple code snippet

public List<Demo1Dto> GridData { get; set; } = new();
private async Task TestPageError(MouseEventArgs arg)
        {
            throw new Exception("throw error");
            
        }
private async Task ReadData(DataGridReadDataEventArgs<Demo1Dto> arg)
        {
            for (int i = 0; i < 10; i++)
            {
                await Task.Delay(1000);
                GridData.Add(new Demo1Dto() { name = "Test" + i});
            }
        }
<Button Size="Size.ExtraLarge" Clicked="TestPageError" Color="Color.Danger">TestPageError</Button>
<DataGrid
    TItem="Demo1Dto"
    Data="GridData"
    ReadData="ReadData"
>
    <DataGridColumns>
        <DataGridColumn Field="@nameof(Demo1Dto.name)" Caption="@nameof(Demo1Dto.name)" ></DataGridColumn>
    </DataGridColumns>
</DataGrid>

Steps to reproduce

When using the ReadData method of the datagrid component to simulate reading data from the database, if any error is triggered on the page (for example, clicking the button to throw an exception in the example code), the ReadData method is executed once. This results in an additional database query. I merely threw an exception, and it inexplicably executed a query, which seems very strange. I think it shouldn't execute a query when an exception is triggered.

What is expected?

When an exception is thrown, the ReadData method should not be executed.

What is actually happening?

1

What browsers do you see the problem on?

Chrome

Any additional comments?

No response

@He-Wu He-Wu added the Type: Bug 🐞 Something isn't working label Jun 13, 2024
@David-Moreira
Copy link
Contributor

That seems very very unlikely, an unhandled exception means that Blazor is being put into an invalid error state.
Blazor Server will disconnect the circuiit, and likewise BlazorWebAssembly, both will be in an invalid state, where the app needs to recover, tipically by refreshing the page/ reloading the app.

So you might have some custom global error handling logic somewhere that wakes the app back up somehow, and your component is just straight up being reloaded, and that's why ReadData gets called again.

So the code you have provided does not allow to reproduce this issue, as a standard blazor app will be in an invalid state since an exception was thrown and not handled.

@David-Moreira David-Moreira added Type: Possible Bug Needs to investigate more to see if it's an actual bug. Status: Repro Missing Area: DataGrid and removed Type: Bug 🐞 Something isn't working labels Jun 27, 2024
Copy link
Contributor

Hello @He-Wu, thank you for your submission. The issue was labeled "Status: Repro Missing", as you have not provided a way to reproduce the issue quickly. Most problems already solve themselves when isolated, but we would like you to provide us with a reproducible code to make it easier to investigate a possible bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: DataGrid Status: Repro Missing Type: Possible Bug Needs to investigate more to see if it's an actual bug.
Projects
None yet
Development

No branches or pull requests

2 participants