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

receiving event blocks promise resolution #64

Open
NodeGuy opened this issue Apr 16, 2017 · 0 comments
Open

receiving event blocks promise resolution #64

NodeGuy opened this issue Apr 16, 2017 · 0 comments

Comments

@NodeGuy
Copy link

NodeGuy commented Apr 16, 2017

TAGG: 0.1.13
Node.js: v6.9.5

Check out this strange code:

'use strict'

const tagg = require('threads_a_gogo')

const thread = tagg.create()

const promise = new Promise((resolve) => {
  thread.on('event', resolve)
  thread.eval(`thread.emit('event', 42)`)
})

promise.then(console.log)

// Without this the promise never resolves.
setImmediate(() => {})

If I don't include setImmediate(() => {}) at the end then the promise never resolves and doesn't print 42 to the console. It looks like the main event loop isn't being processed after receiving an event until I kick it with a null setImmediate.

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

1 participant