I've just figure out that a query on the [transcludedin](https://www.mediawiki.org/wiki/API:Transcludedin) generator with a non-numeric `gtinamespace` throws an error 500 but only after 60 seconds of execution.
Good ones:
* https://en.wikipedia.org/w/api.php?action=query&titles=A&generator=transcludedin>inamespace=0
* https://it.wikipedia.org/w/api.php?action=query&titles=A&generator=transcludedin>inamespace=0
Bad ones:
* https://en.wikipedia.org/w/api.php?action=query&titles=A&generator=transcludedin>inamespace=Test
* https://it.wikipedia.org/w/api.php?action=query&titles=A&generator=transcludedin>inamespace=Test
As far I can see the `transcludedin` module through a `list` is not affected.
Also this is not a problem related to all the generators with a namespace filter e.g. `allpages` quits immediately as expected:
* https://en.wikipedia.org/w/api.php?action=query&titles=A&generator=allpages&gapnamespace=Test
Now I really have no time to further investigate because tomorrow morning I'm in a office.