40ants / reblocks

A fork of Weblocks Common Lisp web framework
https://40ants.com/reblocks/
Other
51 stars 9 forks source link

The variable REBLOCKS/PAGE::*CURRENT-PAGE* is unbound. #61

Open mikeivanov opened 1 month ago

mikeivanov commented 1 month ago

I'm randomly getting an error message saying "The variable REBLOCKS/PAGE::CURRENT-PAGE is unbound." while playing with a slightly modified version of the task list tutorial.

I couldn't figure out the pattern, so I suspect some kind of concurrency bug or whatnot. (sometimes I do noting in the browser and it just pops up in the repl)

Any hints on where to start hunting for it?

svetlyak40wt commented 1 month ago

This is a dynamic variable bound only during the http request processing.

If you are calling some functions relied on this var in the REPL or in a separate thread, then you have to capture the original value of the variable and rebind it in the thread.

For example of such capturing, see this IN-THREAD macro of REBLOCKS-WEBSOCKET system: https://github.com/40ants/reblocks-websocket/blob/master/src/websocket.lisp#L541-L570

Also see this corresponding issue: https://github.com/40ants/reblocks-websocket/issues/4