Skip to content

Commit 1eac157

Browse files
committed
Merge branch 'nrk/fix/various-fixes' into release52-test
2 parents 08625a6 + bd87a6a commit 1eac157

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

meteor/server/publications/partsUI/publication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PartId, RundownPlaylistId, SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids'
2-
import { check } from 'meteor/check'
2+
import { check, Match } from 'meteor/check'
33
import {
44
CustomPublishCollection,
55
SetupObserversResult,
@@ -189,7 +189,7 @@ meteorCustomPublish(
189189
MeteorPubSub.uiParts,
190190
CustomCollectionName.UIParts,
191191
async function (pub, playlistId: RundownPlaylistId | null) {
192-
check(playlistId, String)
192+
check(playlistId, Match.Optional(String))
193193

194194
triggerWriteAccessBecauseNoCheckNecessary()
195195

packages/playout-gateway/src/tsrHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export class TSRHandler {
280280
this.tsr.connectionManager.on('connectionEvent:connectionChanged', (id, status) => {
281281
const coreTsrHandler = this._coreTsrHandlers[id]
282282
if (!coreTsrHandler) return
283+
if (!coreTsrHandler._device) return // Not initialized yet
283284

284285
coreTsrHandler.statusChanged(status)
285286

packages/server-core-integration/src/__tests__/index.spec.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,21 +482,21 @@ describe('coreConnection', () => {
482482
})
483483

484484
// Set child connection:
485-
const coreChild = await coreParent.createChild({
485+
const coreChild0 = await coreParent.createChild({
486486
deviceId: protectString('JestTestChild'),
487487
deviceSubType: PERIPHERAL_SUBTYPE_PROCESS,
488488
deviceName: 'Jest test framework child',
489489
})
490490

491491
const onChildError = jest.fn()
492-
coreChild.on('error', onChildError)
492+
coreChild0.on('error', onChildError)
493493

494-
expect(coreChild.connected).toEqual(true)
494+
expect(coreChild0.connected).toEqual(true)
495495

496496
// Close parent connection:
497-
await coreParent.destroy()
497+
await coreParent.destroy() // This will also close all children
498498

499-
expect(coreChild.connected).toEqual(false)
499+
expect(coreChild0.connected).toEqual(false)
500500

501501
// connect parent again:
502502

@@ -505,10 +505,20 @@ describe('coreConnection', () => {
505505
port: corePort,
506506
})
507507

508-
expect(coreChild.connected).toEqual(true)
508+
// Create a new child connection:
509+
const coreChild2 = await coreParent.createChild({
510+
deviceId: protectString('JestTestChild'),
511+
deviceSubType: PERIPHERAL_SUBTYPE_PROCESS,
512+
deviceName: 'Jest test framework child',
513+
})
514+
515+
const onChildError2 = jest.fn()
516+
coreChild2.on('error', onChildError2)
517+
518+
expect(coreChild2.connected).toEqual(true)
509519

510520
await coreParent.destroy()
511-
await coreChild.destroy()
521+
await coreChild2.destroy()
512522

513523
expect(onChildError).toHaveBeenCalledTimes(0)
514524
expect(onParentError).toHaveBeenCalledTimes(0)

packages/server-core-integration/src/lib/coreConnection.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ export class CoreConnection<
212212
async createChild(coreOptions: ChildCoreOptions): Promise<CoreConnectionChild<PubSubTypes, PubSubCollections>> {
213213
const child = new CoreConnectionChild<PubSubTypes, PubSubCollections>(coreOptions)
214214

215+
this._children.push(child)
216+
217+
// Set the max listeners to a higher value, so that we don't get warnings:
218+
this.setMaxListeners(
219+
// Base count, can be increased if needed:
220+
10 +
221+
// Each child adds 2 listeners:
222+
this._children.length * 2
223+
)
224+
215225
await child.init(this, this._coreOptions)
216226

217227
return child

0 commit comments

Comments
 (0)