Summary
Upon leaving certain biomes after extended trips (Nether and End for both, Mushroom Fields and variants for Patrols only), Patrols and possibly wandering traders that fail the spawn probability check but not the biome check will spawn immediately as soon as the player enters a suitable biome. Note that only one patrol or trader will spawn when the player returns, however, traders will spawn regardless of if one is already present near the area.
Steps to reproduce (Patrols)
Place a repeating command block and a Nether portal.
Set the command block's command to
/kill @e[type=Pillager]
and set it to always be active.Make a behavior pack and copy the vanilla spawn rules for the Patrols.
Change it to spawn the patrols every 60 seconds for normal difficulty, instead of 600-660, and change the spawn chance to 100.
Change the normal difficulty's world age filter to 0.
Load the behavior pack into the world and ensure the difficulty is set to normal.
Wait for the command block to print the kill message, then enter the portal.
Wait 90 seconds in the Nether, then return to the Overworld.
The command block should print that it has killed more pillagers.
Steps to reproduce (Traders)
As wandering trader spawns are not data-driven yet, it's much more difficult to reproduce, but still possible.
Make sure the world you're using to test it is at least 20 minutes old.
Repeat steps 1 and 2, but change the command's target to all
wandering_trader
entities.Wait for the command block to print the kill message, then enter the Nether portal.
Leave the game for a couple of hours. Traders have a random chance of spawning every 20 minutes which goes up after each of the first two spawn failures, so it's best to wait as long as possible before going back to the overworld.
Cross your fingers and hope the command block prints a message.
Observed behavior
Patrols and traders spawn immediately once the player exits the biome/dimension.
Expected behavior
The spawn attempts done in the Nether should completely fail, and spawning should continue as normal once the player returns to the overworld.
Related issues
relates to
Attachments
Comments


I was able to accidentally reproduce this for traders after two extended trips to the end on a survival world. The first time, a trader immediately spawned in the stronghold after I returned, and after going back to the end immediately after and exploring a little more, I returned to find that a second trader had spawned relatively close to the first one. After a little more experimentation I was able to confirm that the bug does affect them just as it does with Patrols.

Fixed in 1.16.