Skip to content
Merged
Changes from 1 commit
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 server/stream/streamBroadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ function startStreamCastBroadcast(value) {
_dontPrintErrors: LoggerManager.logLevel < 2,
});

// Ignore collection events to prevent store in memory
// necessary to prevent memory lead due to the usage
// of DDP subscribe
connection._livedata_data = () => {};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing this actually breaks streamcast, all events are ignored and communication doesn't happen.

another way of preventing this leak to happen, is to actually register a store for the broadcast-stream collection.

so I changed the current line 180 (connection._stream.on('message', function(raw_msg) { for the following code:

	connection.registerStore('broadcast-stream', {
		update({ fields }) {
			const { streamName, eventName, args } = fields;

			if (!streamName || !eventName || !args) {
				return;
			}

			if (connection.broadcastAuth !== true) {
				return 'not-authorized';
			}

			const instance = StreamerCentral.instances[streamName];
			if (!instance) {
				return 'stream-not-exists';
			}

			if (instance.serverOnly) {
				return instance.__emit(eventName, ...args);
			}
			return instance._emit(eventName, args);
		},
	});

looks like even a less hacky solution, wdyt?


connections[instance] = connection;
connection.instanceId = instance;
connection.instanceRecord = {};
Expand Down