In Book 2 of LotR there is a well-known scene in which Gandalf tries to open a secret door via a magic password. Gandalf remarks that "I once knew every spell in all the tongues of Elves or Men or Orcs that were ever used for such a purpose. I can still remember ten score of them without searching in my mind. But only a few trials, I think, will be needed" (I'm quoting from p 324 of my one-volume edition).
Gandalf tries tries many passwords, but none work. We are not told exactly how long passes, only that "the cliff towered into the night, the countless stars were kindled, the wind blew cold, and the doors stood fast."
In RPGing, one way to resolve this would be to have the player recite every magic password that their character has actually learned during th course of play, as noted on the player's character record. This is the sort of thing that the Fighting Fantasy Gamebooks use as part of their puzzle setups (I can certainly recall a key-based one and a gem-based one, and maybe a password-based one also).
Another way is for the player to simply mention that their PC recites a password without actually specifying what it is, while making (say) an Arcana check to see if they recall a correct one. And this could keep going and going in principle ad infinitum if the GM has set the difficulty such that the player can never succeed on the check.
Yet another way is to adopt an approach closer to JRRT's own narration: the player deploys their ability (eg Once Knew Every Spell in the Tongues of Elves or Orcs or Men) against an appropriate difficulty, and the upshot tells us what the next interesting thing in the scene involves (eg in this case, the bored NPC Boromir throws a stone into the pool - a harbinger of approaching trouble!).
None is inherently superior, though these days I have my own preferences for my RPGing. But the third approach is certainly as viable as the other two. Its more relaxed approach to the passage of ingame time, and how that correlates to at-the-table activity, is not any sort of detriment (I can report from experience).