Merge "set the metrics handle correctly on error" into main