mqtt.js client causes event loop to stop

未關閉
#1,031 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
javascript, nodejs
領域
desktop

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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:

  1. Clone the nodegui-starter as described in the Quick Start Guide
  2. npm install @nodegui/nodegui@latest --save
  3. 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();
  1. npm start
  2. Everything works as expected. Woo!
  3. install mqtt module, connect to MQTT server
import * as mqtt from 'mqtt';
mqtt.connect('mqtt://localhost:1883');
  1. Add a button listener, just in case this is related to #864 button.addEventListener('clicked',(checked)=>console.log("clicked"));
  2. 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.

主要語言
C++
星號
9.2k
分支
315
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodegui/nodegui 的其他 Issue

查看 nodegui/nodegui 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。