Skip to content
Snippets Groups Projects
Unverified Commit c8ec3647 authored by Diego Sampaio's avatar Diego Sampaio Committed by GitHub
Browse files

fix: use EJSON serializer for data transfer between multi instances (#31540)

parent e72e39ef
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': patch
---
Fix multi-instance data formats being lost
......@@ -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';
......@@ -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';
......@@ -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),
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment