Skip to content

fix: property access error during rundown deactivation#1762

Open
justandras wants to merge 2 commits into
Sofie-Automation:mainfrom
SuperFlyTV:fix/property-access-error-during-rundown-deactivation
Open

fix: property access error during rundown deactivation#1762
justandras wants to merge 2 commits into
Sofie-Automation:mainfrom
SuperFlyTV:fix/property-access-error-during-rundown-deactivation

Conversation

@justandras
Copy link
Copy Markdown
Member

About the Contributor

This pull request is posted on behalf of the CBC.

Type of Contribution

This is a: Bug fix

Current Behavior

On rundown deactivation, Meteor server intermittently throws:

  • TypeError: attempted to get private field on non-instance

A hot fix was applied in #1753 to prevent Sofie from crashing, but the error remained.

Stack traces point to meteor/server/api/deviceTriggers/StudioObserver.ts inside observer change callbacks (eg. around lines ~222 and ~231), where a class private field access occurs from a callback executed without a valid class instance context.

New Behavior

Rundown deactivation no longer throws the private-field access error.

The observer callbacks no longer depend on this at call time; instead they use captured handler references, so even if the callback is invoked with this === undefined, it executes safely.

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Manual verification:

  • Deactivate a rundown/playlist and confirm the server no longer logs attempted to get private field on non-instance.

Affected areas

  • meteor/server/api/deviceTriggers/* observers
  • Rundown activation/deactivation reactivity (server-side)

Time Frame

Not urgent, but we would like to get this merged into the in-development release.

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@justandras justandras self-assigned this May 28, 2026
@justandras justandras added 🐛🔨 bugfix This is a fix for an issue Contribution from BBC Contributions sponsored by BBC (bbc.co.uk) labels May 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 320c21b8-a5b8-487b-8896-5390027933dd

📥 Commits

Reviewing files that changed from the base of the PR and between dba153c and 58ef28f.

📒 Files selected for processing (2)
  • meteor/server/api/deviceTriggers/StudioObserver.ts
  • meteor/server/api/deviceTriggers/__tests__/StudioObserver.test.ts

Walkthrough

This PR refactors StudioObserver's observer callback handling and adds regression tests. Handler functions are cached before being passed to observer factories, and the PieceInstancesObserver disposer is simplified. A comprehensive test verifies that observer callbacks work correctly when invoked without this binding.

Changes

Observer callback cleanup refactoring and testing

Layer / File(s) Summary
Handler caching and disposer simplification
meteor/server/api/deviceTriggers/StudioObserver.ts
Handler functions are cached into local variables before being passed to RundownContentObserver and PieceInstancesObserver factories. The disposer returned from PieceInstancesObserver.create is simplified to directly invoke the optional cleanup function.
Regression test for observer callback binding
meteor/server/api/deviceTriggers/__tests__/StudioObserver.test.ts
Jest test suite with mocked observers verifies that captured callbacks do not rely on this binding and remain callable. The test primes internal state, triggers observer creation, invokes callbacks unbound, verifies cleanup functions are returned, and asserts underlying handlers are called with expected arguments.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Sofie-Automation/sofie-core#1753: Adjusts piece-instances observer cleanup behavior to ensure callbacks and disposers remain safe after observer stopping, directly related to this PR's disposer refactoring.

Suggested reviewers

  • jstarpl
  • jesperstarkar
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: property access error during rundown deactivation' directly and clearly summarizes the main change—fixing a private field access error that occurs during rundown deactivation.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the bug, the fix approach, testing done, and affected areas.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@justandras justandras requested a review from ianshade May 28, 2026 10:52
@Saftret Saftret added Contribution from CBC/Radio-Canada Contributions sponsored by CBC/Radio-Canada (cbc.radio-canada.ca) and removed Contribution from BBC Contributions sponsored by BBC (bbc.co.uk) labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛🔨 bugfix This is a fix for an issue Contribution from CBC/Radio-Canada Contributions sponsored by CBC/Radio-Canada (cbc.radio-canada.ca)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants