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

Strange bug when sending an object with an async method call to a room #3572

Closed
1 of 2 tasks
brandoncollins7 opened this issue Apr 7, 2020 · 1 comment
Closed
1 of 2 tasks
Milestone

Comments

@brandoncollins7
Copy link

brandoncollins7 commented Apr 7, 2020

You want to:

  • report a bug
  • request a feature

Current behaviour

When including an async method call as a property to the emit object, the send goes to everyone regardless of if they are in the room or not.

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

Not working:

    let pairs = await db('currency_pairs')
    await Promise.all(
        pairs.map(async p => {
            socket.to(`orderbook-${p.id}`).emit('orderbook', {
                orderbook: await orderbook_service.getOrderbook(p.id),
                pairId: p.id
            })
        })
    )

Working:

    let pairs = await db('currency_pairs')
    await Promise.all(
        pairs.map(async p => {
            let orderbook = await orderbook_service.getOrderbook(p.id)
            socket.to(`orderbook-${p.id}`).emit('orderbook', {
                orderbook,
                pairId: p.id
            })
        })
    )

Expected behaviour

What is expected?

emit should only send to users which have been joined to the room

Setup

  • OS: Windows - Node.js
  • browser:
  • socket.io version:
    2.3.0

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

@brandoncollins7 brandoncollins7 changed the title Strange bug when sending and object with an async method call to a room Strange bug when sending an object with an async method call to a room Apr 7, 2020
@darrachequesne
Copy link
Member

Duplicate of #3431

Added in the documentation here, until we fix this behavior in Socket.IO v4.

@darrachequesne darrachequesne added this to the 4.0.0 milestone Feb 23, 2021
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