Blockstream / esplora

Explorer for Bitcoin and Liquid
MIT License
1.02k stars 400 forks source link

prerender: Wait for the loading state to complete, fix HTTP error status codes #530

Closed shesek closed 1 month ago

shesek commented 2 months ago

Prior to this fix, render() preemptively considered the app rendering to be final, before completing the transition out of the loading state entirely.

This resulted in notFound pages not being identified as such, returning them with a 200 OK status code instead of a 404 Not Found.

philippem commented 1 month ago

when testing this (regtest docker, signet container), 400s are returned by the prerender server, not 404s. Here's an example of request from within a bitcoin regtest container, first requesting genesis block, then nonexistent block (changed last digit of block id from 6 to 7)

root@f6b23cb988d3:/srv/explorer# !8
curl -i http://127.0.0.1:80/regtest/nojs/block/0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206 | grep HTTP
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5286  100  5286    0     0  HTTP/1.1 200 OK:--:-- --:--:-- --:--:--     0
 135k      0 --:--:-- --:--:-- --:--:--  135k
root@f6b23cb988d3:/srv/explorer# !9
curl -i http://127.0.0.1:80/regtest/nojs/block/0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2207 | grep HTTP
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2830  100  2830    0     0  97586      0 --:--:-- --:--:-- --:--:-- 94333
HTTP/1.1 400 Bad Request
shesek commented 1 month ago

I see, there are actually two different 'not found' cases here: