It seems likely that the problem is happening at the time the block is connected, with the connection for some reason not being added to the ConnectionDB, but without seeing your code I can't really be sure or understand why.
Can you provide a minimal reproduction for this? That is to so say: an HTML page (containing JavaScript, or including it from a .js file) and a set of instructions that we can use to produce the same error?
Sorry that we can't be of more help here. Do please write back with more information so that we might be able to give you a better answer.
Christopher