Coder Social home page Coder Social logo

Comments (5)

valyrie97 avatar valyrie97 commented on July 26, 2024

update: this seems to be a more general problem with Promises. if you setTimeout, everything works normal. however, creating a loop such as

for(let i = 0; i < 5; i ++) {
    console.log('waiting 1 second');
    await new Promise(res => setTimeout(res, 1000));
}

causes the execution to only return to the resolution of the promise once ive moved to another virtual desktop. (3/4 finger scroll over to a fullscreen app, for example)

This leads me to believe that execution of promise then callbacks is the culprit here.

from qode.

valyrie97 avatar valyrie97 commented on July 26, 2024

Update: After a lot of tinkering, I've isolated that the execution of promise.then(cb) callbacks do eventually get called, but only when the window is updated. This is why when moving between screens, and its focus state changed, promises would resolve.

my current workaround to this (which is terrible for performance), is to have an infinite loop that calls win.update()

function updateLoop() {
    win.update();
    win.repaint();
    setTimeout(updateLoop, 100);
}
updateLoop();

Edit: turns out one needs both a repaint, and an update call to fully allow Promises to resolve. updated workaround code.

from qode.

a7ul avatar a7ul commented on July 26, 2024

Yep this looks like a bug.
Can you see if an older version of qode works for you?
This looks like it might be an issue with recent node version upgrade.

from qode.

valyrie97 avatar valyrie97 commented on July 26, 2024

as i must import nodegui to get the bug to happen, and im getting unrelated errors trying to use a version of qode mismatched with the nodegui version, Im testing each nodegui version here. Each test creates 5 promises resolved after a setTimeout of 0ms.

Each install i rm -rfed the node modules directory, to ensure cleanliness, and always used the version of qode store in node_modules/.bin.

The setup seems to be extremely finicky, so I've also included my test file.

app.js

// swap out import / require for app.js / app.mjs testing
import '@nodegui/nodegui';
// require('@nodegui/nodegui');

function unoMomento() {
  return new Promise(res => {
    setTimeout(res, 0)
  })
}

function doPromise() {
  unoMomento().then(_ => {
    console.log('resolved')
  })
}

doPromise();
doPromise();
doPromise();
doPromise();
doPromise();

setTimeout(_ => {
  console.log('done?')
}, 1000)
nodegui version Resolved Promises ESM CJS
0.34.0 0 0
0.33.3 0
0.33.0 0
0.32.0 0
0.31.0 0
0.30.3 0
0.30.0 *
0.29.0 *
0.28.1 0
0.27.0 0
0.26.0 0
0.25.0 0 0
0.24.0 0 0
0.23.1 0 0
0.23.0 0 0
0.22.0 0 0
0.21.0 0 0
0.15.5 0 0
0.15.4 0 0
0.15.3 0 0
0.15.2 ** **
0.15.1 ** **
0.15.0-alpha-4 ** **
0.15.0-alpha ** **
0.13.4 - 5
0.12.1 - 5
0.6.5 - 5

* came back with an error about not being able to find the binding. '../../../build/Release/nodegui_core.node'

** came back with an error about my QT setup

Blanks are untested; Dashes are ERR_REQUIRE_ESM (assuming an old enough version of node that import syntax wasn't yet mature)

Hope this info is helpful!

from qode.

a7ul avatar a7ul commented on July 26, 2024

This is issue is solved in master branch of qode.
But since I am having some issues with windows build I haven't yet made a release.
In the meantime can you look if this binary solves the issue for you

nodegui/nodegui#862 (comment)

from qode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.