mqtt.js client causes event loop to stop
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, nodejs
- Domain
- desktop
Research direction
Start by reproducing the issue from the nodegui-starter Quick Start setup on Windows with NodeGUI 0.62.0, then compare the label-update loop with and without the mqtt.js connection. The fix is complete when connecting to the MQTT server no longer stops the loop or freezes the QWindow.
Written by the indexing model from the issue text.
Description
Describe the bug
As soon as I connect to an MQTT broker, the event loop stops running and/or becomes very unpredictable.
To Reproduce
Steps to reproduce the behavior:
- Clone the nodegui-starter as described in the Quick Start Guide
npm install @nodegui/nodegui@latest --save- Add a loop to update one of the labels every second
async function loop() {
while(true) {
const timestamp = Math.floor(+new Date() / 1000);
label.setText( `Timestamp: ${timestamp.toString()}` );
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
loop();
npm start- Everything works as expected. Woo!
- install mqtt module, connect to MQTT server
import * as mqtt from 'mqtt';
mqtt.connect('mqtt://localhost:1883');
- Add a button listener, just in case this is related to #864
button.addEventListener('clicked',(checked)=>console.log("clicked")); - The loop executes once, but then gets stuck. Even if I click the button.
Expected behavior
The label should continue to be updated every second, even with a MQTT client present.
Desktop (please complete the following information):
- OS: Windows
- NodeGUI version: 0.62.0
- OS Version: Windows 11
Additional Context
I've tried various other ways of pausing execution, including not using Promises or setTimeout, but this usually ends up freezing the QWindow altogether, resulting in a white, empty window.
- Dominant language
- C++
- Stars
- 9.2k
- Forks
- 315
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nodegui/nodegui
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Support QTransform Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·