Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-tips-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix multi-instance data formats being lost
17 changes: 15 additions & 2 deletions apps/meteor/ee/server/local-services/instance/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import os from 'os';
import { License, ServiceClassInternal } from '@rocket.chat/core-services';
import { InstanceStatus } from '@rocket.chat/instance-status';
import { InstanceStatus as InstanceStatusRaw } from '@rocket.chat/models';
import EJSON from 'ejson';
import type { BrokerNode } from 'moleculer';
import { ServiceBroker, Transporters } from 'moleculer';
import { ServiceBroker, Transporters, Serializers } from 'moleculer';

import { StreamerCentral } from '../../../../server/modules/streamer/streamer.module';
import type { IInstanceService } from '../../sdk/types/IInstanceService';
Expand All @@ -13,6 +14,18 @@ import { getTransporter } from './getTransporter';

const hostIP = process.env.INSTANCE_IP ? String(process.env.INSTANCE_IP).trim() : 'localhost';

const { Base } = Serializers;

class EJSONSerializer extends Base {
serialize(obj: any): Buffer {
return Buffer.from(EJSON.stringify(obj));
}

deserialize(buf: Buffer): any {
return EJSON.parse(buf.toString());
}
}

export class InstanceService extends ServiceClassInternal implements IInstanceService {
protected name = 'instance';

Expand Down Expand Up @@ -83,7 +96,7 @@ export class InstanceService extends ServiceClassInternal implements IInstanceSe
this.broker = new ServiceBroker({
nodeID: InstanceStatus.id(),
transporter: this.transporter,

serializer: new EJSONSerializer(),
...getLogger(process.env),
});

Expand Down