Why Do Async JavaScript Functions Throw Errors in Release Mode Build?
-
wrote on 17 Mar 2025, 12:24 last edited by
Hello,
I am developing a Qt application using WebChannel to display HTML. While everything works fine in Debug mode, I am encountering errors in JavaScript async functions when building the application in Release mode.
Problem Description:
In Debug mode, async functions work correctly without any issues.
However, when building in Release mode, errors appear in async functions.
The error messages are typically related to syntax errors, such as "Expected token ;".
Only async functions are affected—other code works fine.
Example of Problematic Function:async function set_edit(_e) { var offset = {}; offset['x'] = _e.target.offsetLeft; offset['y'] = _e.target.offsetTop; offset['offsetX'] = _e.offsetX; offset['offsetY'] = _e.offsetY; const ret = await parent.edit_text({ "offset": offset, "pick": pick, "page": page, "canvas": canvas }); if (ret === true) { this.hide(); } };
In this code, the async function set_edit throws errors in Release mode. Other functions do not have this problem.
Additional Information:
The same errors appear in various files, and when I delete certain files and rebuild, the errors shift to different locations.
For example, another function handleImage also has the same issue:async function handleImage(status = false) { try { var decodedString = await wpubManager.getImgObject(); let page = await wpubManager.getPage(); if (decodedString) { const point = await window.wpubManager.getImagePosJSON(); currentX = point.x; currentY = point.y; preDrawCanvas(decodedString, currentX, currentY); resetZoom(); } else { var indexedDBId = await wpubManager.getIndexedDBId(); if (indexedDBId !== '') { try { const indexedImage = await fetchImageFromIndexedDB(indexedDBId, page); if (indexedImage) { preDrawCanvas(indexedImage, 0, 0); resetZoom(); } else { console.error("No image data found in IndexedDB for ID:", indexedDBId); } } catch (error) { console.error("Error fetching image from IndexedDB:", error); } } else { console.error("No IndexedDB ID received from wpubManager."); } } selectElement.selectedIndex = page - 1; if (status) getCount(); } catch (error) { console.error("Error in handleImage function:", error); } }
Questions:
Why do async functions throw errors only in Release mode?
Could optimization settings be the cause of these issues? How can I resolve this?
Are there any known bugs related to async functions in Qt when building in Release mode?
I’ve already checked optimization settings and the build environment but still cannot solve the issue. If anyone has had similar experiences or knows how to fix this, your advice would be greatly appreciated.
Thank you! -
wrote on 17 Mar 2025, 14:28 last edited byThis post is deleted!
1/2