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

Using acknoledgment doesn't work with async code #553

Closed
2 tasks done
Sharcoux opened this issue Jan 22, 2018 · 1 comment
Closed
2 tasks done

Using acknoledgment doesn't work with async code #553

Sharcoux opened this issue Jan 22, 2018 · 1 comment

Comments

@Sharcoux
Copy link

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • report a bug
  • request a feature

Current behaviour

emitting an event on the server, if the server makes asynchronous treatment before calling ack, null will be retrived to the client before the server could have a chance to response.

Steps to reproduce (if the current behaviour is a bug)

client-side

 socket.emit('event', console.log)

server-side

 socket.on('event', callback => {
    new Promise(resolve => setTimeout(() => resolve('ok'), 1000)).then(callback);
}

Expected behaviour

Log "ok" client side

Current result

Log "null" client side

Setup

  • OS: MacOs
  • browser: Firefox
  • engine.io version: 2.0.4

Other information (e.g. stacktraces, related issues, suggestions how to fix)

I think that the issue is that socket.io probably send back "null" to the client if no listener used the acknoledgment function. I think that the best would be for socket.io to provide an option that would prevent this behaviour in exchange for ensuring that the server will provide an answer, or timeout.

@darrachequesne
Copy link
Member

This seems to be fixed in latest versions (both in socket.io@2 and socket.io@3). Please reopen if needed.

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