node-red-quantum / node-red-contrib-quantum

Quantum computing functionality for Node-RED
https://node-red-quantum.github.io/
Apache License 2.0
18 stars 2 forks source link

`await circuitReady` freezes execution in `quantum-register.js` #87

Closed louislefevre closed 3 years ago

louislefevre commented 3 years ago

Bug Description

When executing a quantum register for the first time in a fresh Node-RED session, the await circuitReady code will freeze execution. If the circuit is re-run a second time during the same session, it will run just fine. Essentially, this bug only occurs when the circuit is being run for the first time in a given session. After that, it runs fine.

Steps to Reproduce Bug

simple-circuit

Additional Information

https://github.com/louislefevre/node-red-contrib-quantum/blob/46a8320cb304cc4b58438429b398bc780ad7d832/quantum/nodes/quantum-register/quantum-register.js#L105

System Information

bbaayezi commented 3 years ago

The bug was caused by emitting the circuitReady event before the quantum register nodes advanced to await circuitReady() line. A slight change in execution order and use process.nextTick() to emit event solves the issue.