Skip to content

Conversation

@jstarpl
Copy link
Contributor

@jstarpl jstarpl commented Jan 9, 2026

About the Contributor

This pull request is posted on behalf of the NRK.

Type of Contribution

This is a:

Bug fix

Current Behavior

The event handler for connectionEvent:debug inside playout gateway's tsrHandler.ts is a bit too nosy, checking the device config, before forwarding the logging to the logger. If for whatever reason, the config states between the two sides gets mismatched, the logging will not be forwarded.

New Behavior

Since device-level logging filtering is already handled by TSR, there's no point in checking this twice. Checking if top-level debug logging is enabled at this point should be enough.

Additionally, handle a case if a non-Error value is emitted (such as undefined) in fixError.

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

Affected areas

This PR fixes a potential issue in the logging output of Playout Gateway.

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.

Summary

This PR removes redundant device-level debug logging filtering from the Playout Gateway's tsrHandler.ts file, and improves error handling for non-Error values.

Changes

Debug Logging Gate Simplification (lines 374-387)

  • The connectionEvent:debug handler now gates debug output solely by the global logDebug flag, removing a device-level debugLogging check that was previously applied
  • This allows debug messages to be emitted whenever global debug logging is enabled, regardless of individual device configuration states
  • Rationale: Eliminates duplicate filtering that could suppress logs when device-config state mismatched between different parts of the system; TSR now handles device-level filtering directly

Error Handling Robustness (lines 261-276)

  • The fixError helper function now explicitly handles non-Error values (e.g., undefined, plain objects)
  • When an error object lacks a message property, the function returns a simplified error object with only a generated message (including device name and stringified error representation)
  • Previously, such values would be processed without explicit type checking

Impact

  • Logging behavior: Debug messages from device connections may now be emitted more freely when global debug logging is enabled
  • Error handling: More resilient handling of unexpected error types emitted to the connection event handler
  • No public API changes; affects internal logging of Playout Gateway operations

@jstarpl jstarpl requested a review from a team as a code owner January 9, 2026 15:32
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Walkthrough

The TSR handler was modified to simplify error object generation when messages are missing, returning only a generated message with device name and stringified error. Additionally, debug logging for connection events is now controlled solely by the global logDebug flag, removing per-device debugLogging checks.

Changes

Cohort / File(s) Summary
TSR Handler Error and Debug Updates
packages/playout-gateway/src/tsrHandler.ts
Modified error fixer to return simplified error objects containing only generated messages when error message is absent. Changed debug logging to use global logDebug flag exclusively, removing per-device debugLogging condition for connection event logging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop, skip, and simplified bound,
Error messages now lean and sound,
Debug logs dance to one global beat,
No per-device checks to repeat!
Cleaner flows make this quite neat.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: remove over-eager debug logging filtering from connectionManager' accurately describes the main change: removing a device-level debug logging filter in the TSR connection handler to address over-filtering of debug logs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e012da and 74fa18a.

📒 Files selected for processing (1)
  • packages/playout-gateway/src/tsrHandler.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Lint Package (live-status-gateway-api)
  • GitHub Check: Test Package (main) (openapi, 22.x)
  • GitHub Check: Lint Package (playout-gateway)
  • GitHub Check: Lint Package (corelib)
  • GitHub Check: Lint Package (meteor-lib)
  • GitHub Check: Lint Package (job-worker)
  • GitHub Check: Lint Package (webui)
  • GitHub Check: Lint Package (openapi)
  • GitHub Check: Test Package (main) (22.x, webui, true)
  • GitHub Check: Lint Package (mos-gateway)
  • GitHub Check: Test Package (main) (22.x, job-worker, true)
  • GitHub Check: Publish Docs
  • GitHub Check: Test Core
  • GitHub Check: Typecheck and Lint Core
🔇 Additional comments (2)
packages/playout-gateway/src/tsrHandler.ts (2)

265-269: LGTM! Improved error handling for non-Error values.

The new guard correctly handles cases where the error parameter is null, undefined, or a non-Error object. The simplified return structure (message only) is appropriate for these edge cases while preserving the full error structure (message, name, stack) for proper Error objects in the existing code below.


377-377: LGTM! Simplified debug logging to use only global flag.

The removal of device-level debug filtering is correct per the PR objective. This prevents logs from being suppressed when device configuration states mismatch between the Gateway and TSR. The device reference on line 375 is still appropriately used for log context on line 385.


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.

@jstarpl
Copy link
Contributor Author

jstarpl commented Jan 9, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jstarpl jstarpl added the Contribution from NRK Contributions sponsored by NRK (nrk.no) label Jan 9, 2026
@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from NRK Contributions sponsored by NRK (nrk.no)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants