Skip to content

Guard LogInterceptor flush against OSError#13931

Open
YUHAO-corn wants to merge 1 commit into
Comfy-Org:masterfrom
YUHAO-corn:yuhao/fix-loginterceptor-flush-oserror
Open

Guard LogInterceptor flush against OSError#13931
YUHAO-corn wants to merge 1 commit into
Comfy-Org:masterfrom
YUHAO-corn:yuhao/fix-loginterceptor-flush-oserror

Conversation

@YUHAO-corn
Copy link
Copy Markdown

Summary

  • ignore OSError raised by the wrapped stdout/stderr stream during LogInterceptor.flush()
  • still run flush callbacks after the underlying flush fails
  • add a focused unit test for the invalid-argument flush path

This only suppresses errors from the underlying stream flush. Callback exceptions still propagate as before.

Fixes #13906

Tests

  • python3 -m pytest tests-unit/app_test/logger_test.py
  • python3 -m py_compile app/logger.py

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 29f8a40f-ca47-4745-b285-597fe6d01834

📥 Commits

Reviewing files that changed from the base of the PR and between 0039804 and 276bfe0.

📒 Files selected for processing (2)
  • app/logger.py
  • tests-unit/app_test/logger_test.py

📝 Walkthrough

Walkthrough

This PR makes LogInterceptor.flush() resilient to stream flush failures. The method now catches OSError exceptions from the underlying stream flush operation, silently ignoring them while continuing to execute registered flush callbacks and clear the buffered logs. A new unit test verifies that callbacks receive buffered logs and _logs_since_flush is cleared even when an OSError is raised during the flush attempt.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding error handling for OSError in LogInterceptor.flush().
Description check ✅ Passed The description is directly related to the changeset, explaining the OSError handling, callback execution, and testing approach.
Linked Issues check ✅ Passed The code changes fully address issue #13906 by wrapping super().flush() in try/except OSError and ensuring callbacks still run.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the OSError handling in LogInterceptor.flush() and adding the corresponding unit test.

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


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.

@YUHAO-corn YUHAO-corn force-pushed the yuhao/fix-loginterceptor-flush-oserror branch from 403c7c5 to 0039804 Compare May 22, 2026 19:04
@YUHAO-corn YUHAO-corn force-pushed the yuhao/fix-loginterceptor-flush-oserror branch from 0039804 to 276bfe0 Compare May 23, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LogInterceptor.flush() raises OSError when custom nodes or comfyui-manager wrap stdout

1 participant