Closed ttoktassynov closed 3 years ago
Seems to be caused by the registerArr
variable in quantum-register.js
. On first execution, its initial value is []
. On second execution, its initial value is undefined
.
Also, it's worth noting that this behaviour happens in the same loop:
Okay so I think I figured out the cause. This is the flow of execution:
quantum-circuit
node is loaded, initialising registers
to an empty array in the global state.state.del('registers')
is executed, setting registers
to undefined
. The flow still finishes executing successfully.quantum-circuit
has not been re-loaded (therefore initialising registers
to an empty array again), registers
is still left as undefined
from the previous run.registers
being undefined, an error occurs in Node-RED. Node-RED will automatically restart everything when this happens, which in turn causes quantum-circuit
nodes to be re-loaded, thereby initialising registers
to an empty array again. So the reason every other execution works is because Node-RED is automatically restarting everything behind the scenes.A fix I've just quickly tested that seems to work is to replace all instances of state.del('registers')
with state.setPersistent('registers', [])
. However, I'm not sure if this will have any unforeseen consequences, since registers
is no longer removed completely like it was before.
Maybe try to implement in different branch and see if tests pass?
Maybe try to implement in different branch and see if tests pass?
The tests still pass locally, but since we don't have tests for all scenarios I'm still unsure as I don't know the reason for deleting 'registers' from the state in the first place.
Bug Description
When injecting input to the register only circuit a second time in a row, after first successful input, we receive following error of Quantum Register:
Most likely it has to do with state management functionanility.
Steps to Reproduce Bug
Draw this circuit:![Screen Shot 2021-09-07 at 21 50 14](https://user-images.githubusercontent.com/25239936/132409119-bafaab1c-b613-4965-9ed3-77d4aa4a4590.png)
or simply import this json
Expected Behaviour & Actual Behaviour
Additional Information
Log file can be found here.
System Information
Node.js Version: v12.22.1
Operating System:Darwin tma.local 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64