Consider a PN junction diode
Now, this system will naturally form a depletion region due to diffusion and will convert into this:
Now, I wish to connect the ends of this diode with a conducting wire and resistance like this:
Thus, I expect the electric field in this space to be aligned as follows (indicated dim green:)
This will make the charges in the wire accumulate in the following way:
Finally, this system will end up neutralizing all the charges so that no electric field remains inside and outside the diode; creating equilibrium state for the free charges. So, we are going to be back on a simple P-N junction diode with no depletion region and no electric fields.
However, this will again create a difference in electron concentration between N and P sides; these high-speed free electron will naturally flow from N-side to P-side creating an electric field which would later be balanced by the conducting wire.
I thus expect this cycle to go on and on leading to continuous charge flow through the resistance. Overall, the diode will be taking up heat from the surroundings, while the resistance would be releasing heat there.
Obviously I expect this analysis to be wrong, but I am not able to figure out where did I made any mistake.
PS: I asked this question originally at the Physics StackExchange, but they consider it to be similar to (https://physics.stackexchange.com/questions/108314/why-isnt-there-a-potential-difference-across-a-disconnected-diode). However, I am still not satisfied because I am not finding where I am going wrong. Simply stating that there is no potential difference across the diode is of no help.
Here, I have used basic core principles of electrodynamics only. I would be grateful if someone points out the exact step where I am making the blunder.