Websocket changes feed not returning all docs in bucket

I want to set up an event driven process that runs when documents come through on a particular channel. So I have hooked up a websocket to the sync gateway changes feed but not all documents come through when compared to the original sync gateway bucket.

The websocket is hooked up to:

wss://server/my-db/_changes?feed=websocket&filter=sync_gateway%2Fbychannel&channels=my-channel

Then as per websocket wiki I send through an initial request from my client with:

since = 1,
include_docs = true

However, I receive less documents than exists in the sync gateway bucket:

Count by websocket feed: 83
Count by N1QL query: 118

Also to note that during processing, the websocket receives some empty arrays through like [ ].

Gist of logs

SG config

{
  "log": ["*"],
  "databases": {
    "db": {
      "server": "http://server:8091",
      "bucket": "my-db",
      "users": { "adminUser": { "password": "adminPassword", "admin_channels": ["*"], "disabled": false } },
      "oidc": {
	"default_provider": "oidc1",
        "providers": {
          "oidc1": {
            "issuer":"https://authserver",
            "client_id":"clientId",
            "validation_key":"secretKey",
            "register":true
          }
        }
      },
      "sync": `mysyncfunction` 
    }
  }
}

Version: 1.4.1(3;ddffd85)

Any ideas what’s going wrong here?

Found the issue. The data returned was an array that sometimes contains multiple items. I was only selecting the first, as it usually on returned one.This condition from the wiki is obviously the case now:

(The current server implementation sends at most one notification per message, but this could change. Clients should accept any number.)