Skip to content

Partial omission of emitted object if jsonification fails #5225

Open
@eldir

Description

@eldir

Describe the bug
When passing an object to an emit that contains a function reference it just quietly gets omitted.

To Reproduce

function test_function() {
  return null;
}

const data = {
  key_one: "value 1",
  key_two: test_function
}

socket.emit("test", data);

Checking traffic will show that test gets a message containing only

{
  "key_one": "value 1"
}

With no error or even warning on the console.

Expected behavior
If jsonification fails (which is what I suspect is happening here) I would expect at least a warning or a full transmission failure and not quiet removal of part of the transmitted object.

Platform:

  • Device: PC
  • OS: Ubuntu 24.04.1 LTS
  • tested on socket.io client 4.7.5 and 4.8.1

Additional context
For context we initially found this with a misconfigured value from redux. A console.log(data) will produce the full object as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions