Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promises don't work in the monitor callback! #24

Open
nbroeking opened this issue Jun 27, 2017 · 2 comments
Open

Promises don't work in the monitor callback! #24

nbroeking opened this issue Jun 27, 2017 · 2 comments

Comments

@nbroeking
Copy link

nbroeking commented Jun 27, 2017

const udev = require('udev');
const monitor = udev.monitor();

monitor.on('add', () => {
  console.log('1');
  Promise.resolve()
  .then(() => {
    console.log('2');
  })
  .then(() => {
    console.log('3');
  });
});

Output should be:

1
2
3

Output is

1

However if you do

monitor.on('add', () => {
  console.log('1');
  setTimeout(() => {
    Promise.resolve()
    .then(() => {
      console.log('2');
    })
    .then(() => {
      console.log('3');
    });
  })
});

Then the output is

1
2
3

@nbroeking
Copy link
Author

@KevinDyer

@cheery
Copy link
Owner

cheery commented Jun 27, 2017

If the Promise.resolve() works outside, then the culprit is likely in the function
on_handle_event at udev.cc:51.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants