ResultSet returned by subscribe() in production mode is different from dev mode: return requestId in production mode
- Dominant language
- Rust
- Stars
- 20.8k
- Forks
- 2.1k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 181
Description
Hi guys,
For the last months I've been working on an analytics platform that's using Cube in the background. I've configured many dashboards, with the majority having real time indicators. I've built everything while working with `dev mode = true` but recently, due to the proximity to the client delivery I've started making tests with Cube configured in production mode. For that I've followed the steps you have in the documentation but one problem appeared.
I'm using the `subscribe` function to listen on changes related to the real time indicators and I've noticed that the `resultSet` that is returned have less fields in production mode.
Here you can see, the result set returned with `dev mode = true`

And here you can see the result set returned with `dev mode = false`

The problem is, I'm in need of the `requestId` of every single indicator, because it is the only way i know so later i can unsubscribe that request.
One real use case that I have is, I have one real time indicator with the time filter "today", and for this I subscribe it. If I change the time filter for yesterday, i will create a new subscription, because it's a new query, and for this I need to unsubscribe the previous one.
I'll leave a peace of my code and note that I use the `requestId` so I can store the `messageId` associated in the html so later I can use `sendMessage` to unsubscribe.
```
cubejsApiWebTransport.subscribe(request, {}, (error, resultSet) => {
var requestId;
if(resultSet != null && resultSet.loadResponses[0] != null){
requestId = resultSet.loadResponses[0].requestId;
var messages = cubejsApiWebTransport.transport.messageIdToSubscription;
Object.keys(messages).forEach(function(key,index) {
var newMessageId = key;
var newRequestId;
if(messages[newMessageId] != null && messages[newMessageId].message != null){
newRequestId = messages[newMessageId].message.requestId;
if(requestId != null && requestId.indexOf(newRequestId) >= 0){
indContainer.attr('data-messageId', newMessageId);
}
}
});
}
...
```
As I said in the beginning, this is working fine with `dev mode = true` and I would like to understand if in production mode there is a way to force cube to send the `requestId` or to get it in other way.
**Version:**
0.33.38
Thanks in advance,
Filipe
Contributor guide
Assessment
This issue has not been assessed yet.