File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
apps/postgres-new/components Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,17 @@ export default function AppProvider({ children }: AppProps) {
138138 if ( isStartupMessage ( message ) ) {
139139 const parameters = parseStartupMessage ( message )
140140 if ( 'client_ip' in parameters ) {
141- setConnectedClientIp ( parameters . client_ip === '' ? null : parameters . client_ip )
141+ // client disconnected
142+ if ( parameters . client_ip === '' ) {
143+ setConnectedClientIp ( null )
144+ // we ensure we're not in a transaction block first
145+ await db . sql `rollback;` . catch ( )
146+ // we clean the session state, see: https://www.pgbouncer.org/faq.html#how-to-use-prepared-statements-with-session-pooling
147+ // we do this to avoid having old prepared statements in the session
148+ await db . sql `discard all;`
149+ } else {
150+ setConnectedClientIp ( parameters . client_ip )
151+ }
142152 }
143153 return
144154 }
You can’t perform that action at this time.
0 commit comments