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

Connection event seems to trigger sync #29

Open
topaxi opened this issue Apr 15, 2016 · 1 comment
Open

Connection event seems to trigger sync #29

topaxi opened this issue Apr 15, 2016 · 1 comment

Comments

@topaxi
Copy link

topaxi commented Apr 15, 2016

Given something like:

  let srv = Mitm()
  let client = irc.Client.create({
    host: 'irc.example.com',
    port: 6667,
    nick: 'topaxi',
    user: 'topaxi'
  })
  let subscription = client.subscribe()

  srv.on('connection', () => {
    subscription.unsubscribe()
    srv.disable()
    done()
  })

The subscription will be undefined in the connection event, this makes it kinda hard to write tests without introducing manual process.nextTick(...) calls.
I've tried putting the subscribe() call below the 'connection' event, but this won't work as connection will be triggered inside my subscribe call (because Mitm seems to make this sync).

@moll
Copy link
Owner

moll commented Jun 3, 2016

Hey!

Thank you taking the time to report this! You're right, they are sync now indeed. I wonder if there are any implications in making connection it async. Don't seem to be.

You could in theory until then listen to the connect event on the server-side socket and unsubscribe there. The server socket is the first argument passed to the connection event.

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