fix: PR feedback to move defer logic to its own function for clarity
fix: PR feedback to move defer logic to its own function for clarity

influxdb/influxdb,influxdb/influxdb,influxdata/influxdb,influxdb/influxdb,influxdb/influxdb,influxdb/influxdb,li-ang/influxdb,li-ang/influxdb,influxdata/influxdb,influxdb/influxdb