Skip to content

receiving event blocks promise resolution #64

Description

@NodeGuy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions