I know there are a lot of moving parts to this issue but I think I've eliminated most of them and the problem comes down to the postgresql server generating a statement_timeout error after 10 seconds when the connection statement_timeout is actually set to 15 minutes.
My web server gets a database handle which it keeps for the duration of the function that generates the response. Multiple queries can be sent and will use the same handle.
After getting the handle I issue "show statement_timeout" and log the result which shows 15 minutes.