Recently I've used a virus and lost it. It didn't affect the targeted portal and it went away from my inventory. Why and how did it happen? Was that a system glitch? Did someone else experience something like this before?
If you use a virus on a recently flipped (in the last hour) portal your virus will be consumed without a warning. You'll only get a message after using the virus telling you that the targeted portal is immune to the process.
This from a formal Ingress post :
Portals now have a temporary 1 hour immunity to ADA Refactor and JARVIS Virus weapons after a Refactor or Virus has been deployed. If immune, Agents should see: "Failed. Portal Temporarily Immune."
This is important: Failed attempts to use an ADA Refactor or JARVIS Virus weapon will consume the Refactor and Virus, removing it from your inventory.