Redis-cli hangs when deleting keys

I’m running the following command in a docker container with redis-cli 6.2 to delete some keys with a specific pattern

redis-cli -u rediss://redis:xxx --cacert /opt/bitnami/redis/certs/redis.pem --tls --no-auth-warning --scan --pattern "test*" | xargs redis-cli -u rediss://redis:xxx --cacert /opt/bitnami/redis/certs/redis.pem del --verbose

The command hangs and I’m not getting any response. It seems this error is random. Anyone else having this issue and how to resolve this?