web: don't hang when reloading the file, eg after adding a transaction (#1409)
This was caused by an circular reference in an untested code path
in getViewData, added some months ago (lines 211-212 in 260283e2:
"lib,cli,ui,web: Introduce ReportSpec, which holds ReportOpts, the day of the report, and the parsed Query.").
This kind of bug unfortunately seems to be easy to create in Haskell,
and sometimes quite tedious to track down.
For this particular case, we should add a suitable test to the hledger-web
test suite, and/or set up a pre-release human test script, like hledger-ui's.
The bug was very obvious to the first downloader of hledger-web 1.20,
but it seems over the last three months nobody used a hledger-web built
from master. Providing and encouraging use of nightly builds could also help.
			
			
This commit is contained in:
		
							parent
							
								
									fa28b43aed
								
							
						
					
					
						commit
						69edf9003e
					
				| @ -205,17 +205,14 @@ instance Show Text.Blaze.Markup where show _ = "<blaze markup>" | |||||||
| -- | Gather data used by handlers and templates in the current request. | -- | Gather data used by handlers and templates in the current request. | ||||||
| getViewData :: Handler ViewData | getViewData :: Handler ViewData | ||||||
| getViewData = do | getViewData = do | ||||||
|   App {appOpts = opts, appJournal} <- getYesod |   App{appOpts=opts@WebOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{rsOpts}}}, appJournal} <- getYesod | ||||||
|   today <- liftIO getCurrentDay |   today <- liftIO getCurrentDay | ||||||
|   let copts = cliopts_ opts |  | ||||||
|       rspec = (reportspec_ copts){rsOpts=ropts} |  | ||||||
|       ropts = (rsOpts rspec){no_elide_ = True} |  | ||||||
| 
 | 
 | ||||||
|   -- try to read the latest journal content, keeping the old content |   -- try to read the latest journal content, keeping the old content | ||||||
|   -- if there's an error |   -- if there's an error | ||||||
|   (j, mjerr) <- getCurrentJournal |   (j, mjerr) <- getCurrentJournal | ||||||
|                 appJournal |                 appJournal | ||||||
|                 copts {reportspec_ = rspec} |                 copts{reportspec_=rspec{rsOpts=rsOpts{no_elide_=True}}} | ||||||
|                 today |                 today | ||||||
| 
 | 
 | ||||||
|   -- try to parse the query param, assuming no query if there's an error |   -- try to parse the query param, assuming no query if there's an error | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user