Page MenuHomePhabricator

[explorer] Prevent datatables ajax error popup
ClosedPublic

Authored by bytesofman on Aug 13 2024, 18:35.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC63b310013738: [explorer] Prevent datatables ajax error popup
Summary

When DataTables fails to populate a table with data from the server API, it triggers a pop-up with a user-unfriendly error msg. Reloading the page will usually correct the error. However the user is not informed of this.

Implement custom error handling function instead of this default datatables behavior. When we experience a datatables error, we reload the page (without params, in case the user was trying to load e.g. http://localhost:3035/?rows=1000 which is expected to fail as the API will not provide this many blocks).

If this fails to solve the issue, next step would be to get the required data manually from an API call -- where we can control the try...catch behavior -- then load the table only when we have good data, e.g. https://datatables.net/examples/data_sources/js_array.html

Test Plan

This diff definitely ends the behavior of "unhelpful datatables popup." I am not sure if the auto-reload-on-error behavior will work in practice or not, as I am not able to reliably recreate the datatables error on load with no params. However, I was able to test this behavior by intentionally throwing the error, e.g. http://localhost:3035/?rows=1000 after setting MAX_ROWS_RENDER to > 1000 -- page just reloads quickly to home, no issue detectable by user.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
explorer-table-error-fix-take-two
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29968
Build 59470: Build Diff
Build 59469: arc lint + arc unit

Event Timeline

bytesofman edited the summary of this revision. (Show Details)
bytesofman added inline comments.
web/explorer/explorer-server/code/blocks.js
93

This is the new version of datatables syntax for the same thing. Should have been implemented in the last diff.

...could split it out of this diff, but imo, we are iterating through with this same package in all of these diffs, easy enough to track them here

https://datatables.net/manual/api

124

Trying to select 500 or 1000 reliable threw an API error

189

I don't know what this used to be. But we no longer have a .datatable__length-placeholder class in the DOM, so it's dead code

193

new syntax as we upgraded DataTables in the last diff

Fabien added inline comments.
web/explorer/explorer-server/code/blocks.js
74

This is unreachable since you removed 500 and 1000 from the list ?

bytesofman added inline comments.
web/explorer/explorer-server/code/blocks.js
74

it's hard to get to. but you can always type it in the URL

?rows=1000

So someone could select 250, then manually replace 250 as a param with anything

This revision is now accepted and ready to land.Aug 13 2024, 20:31
This revision was automatically updated to reflect the committed changes.
bytesofman marked an inline comment as done.