Skip to content

fix(export): restore console log level after export completes - #7947

Open
DevChiniwala wants to merge 1 commit into
reflex-dev:mainfrom
DevChiniwala:fix/deploy-restore-loglevel
Open

DevChiniwala wants to merge 1 commit into
reflex-dev:mainfrom
DevChiniwala:fix/deploy-restore-loglevel

Conversation

@DevChiniwala

@DevChiniwala DevChiniwala commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7850

Summary

  • export() sets the console to the subprocess log level (WARNING by default) but never restores it
  • This hides all INFO messages from callers like reflex deploy after the export step — deployment progress, scaling-conflict retries, and the success line are all silenced
  • Fix: save the current log level before export() changes it and restore it in the existing finally block

Changes

  • reflex/utils/export.py: save prev_log_level via _log.get_log_level() before set_log_level(loglevel), restore it in the finally block

Test plan

  • reflex deploy in a non-TTY shell should now show progress and success messages after the export step
  • The fix is in the existing finally block, so the level is restored even if export fails

🤖 Generated with Claude Code

View guided diff

@DevChiniwala
DevChiniwala requested a review from a team as a code owner November 20, 2026 20:13
Copilot AI balanced review requested due to automatic review settings November 20, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The new test cleanup issue is non-blocking.

Findings

  1. P2 Tests leave logging settings behind ▶

Summary

The PR restores the caller's console log level after export finishes.

  • Export restores the caller's log level when it finishes.

Reviews (6) · Last reviewed commit: "fix(export): restore console log level a..." · Reviewed by Greptile

Comment thread reflex/utils/export.py Resolved
Comment thread reflex/utils/export.py Resolved
@codspeed

codspeed Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 6.41%

3 warnings

⚠️ 16 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

❌ 3 regressed benchmarks
✅ 143 untouched benchmarks
⏩ 8 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_route_matching[1000] 90 ms 96.8 ms -6.93%
❌ test_route_matching[100] 9.4 ms 10.1 ms -6.81%
❌ test_route_matching[10] 1.2 ms 1.3 ms -5.49%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing DevChiniwala:fix/deploy-restore-loglevel (9797836) with main (df7f157)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@DevChiniwala
DevChiniwala force-pushed the fix/deploy-restore-loglevel branch from 0951824 to fe2e381 Compare November 20, 2026 23:09
Comment thread tests/units/utils/test_export.py Resolved
Comment thread tests/units/utils/test_export.py Resolved
Comment thread tests/units/utils/test_export.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4 issues found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/units/utils/test_export.py">

<violation number="1" location="tests/units/utils/test_export.py:4">
P2: This import is unused and causes Ruff’s `F401` check to fail; remove it. The import block should retain only the used `pytest` import and project imports.</violation>

<violation number="2" location="tests/units/utils/test_export.py:13">
P2: This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.</violation>

<violation number="3" location="tests/units/utils/test_export.py:21">
P2: These tests do not exercise log-level restoration because the fixture mocks the `console` object used by `export()`. Mock only `console.rule` (or remove this patch) so `set_log_level()` remains real and the assertions can detect a regression.</violation>
</file>

<file name="changes/7947.bugfix.md">

<violation number="1" location="changes/7947.bugfix.md:1">
P2: Towncrier will ignore this fragment because root release notes are read from `news/`, not `changes/`; move it to `news/7947.bugfix.md` so the fix is included in the changelog.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/units/utils/test_export.py Outdated

import pytest
from pytest_mock import MockerFixture
from unittest.mock import patch, MagicMock

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This import is unused and causes Ruff’s F401 check to fail; remove it. The import block should retain only the used pytest import and project imports.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 4:

<comment>This import is unused and causes Ruff’s `F401` check to fail; remove it. The import block should retain only the used `pytest` import and project imports.</comment>

<file context>
@@ -1,274 +1,75 @@
 
 import pytest
-from pytest_mock import MockerFixture
+from unittest.mock import patch, MagicMock
 from reflex_base import constants
+from reflex_base.utils import console
</file context>

Comment thread tests/units/utils/test_export.py Outdated
api_url="https://api.example.com",
deploy_url="https://app.example.com",
)
def mock_dependencies(mocker):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 13:

<comment>This rewrite drops the only coverage for export telemetry, phase timing, lock lifecycle, and backend archive behavior while adding only mocked log-level checks. Retain the existing export tests and add the restoration cases instead of replacing the suite.</comment>

<file context>
@@ -1,274 +1,75 @@
-        api_url="https://api.example.com",
-        deploy_url="https://app.example.com",
-    )
+def mock_dependencies(mocker):
+    """Mock all export dependencies to isolate log level testing."""
+    mocker.patch("reflex.utils.export.get_config")
</file context>

Comment thread tests/units/utils/test_export.py Outdated
mocker.patch("reflex.utils.export.prerequisites")
mocker.patch("reflex.utils.export.build")
mocker.patch("reflex.utils.export.exec")
mocker.patch("reflex.utils.export.console")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: These tests do not exercise log-level restoration because the fixture mocks the console object used by export(). Mock only console.rule (or remove this patch) so set_log_level() remains real and the assertions can detect a regression.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 21:

<comment>These tests do not exercise log-level restoration because the fixture mocks the `console` object used by `export()`. Mock only `console.rule` (or remove this patch) so `set_log_level()` remains real and the assertions can detect a regression.</comment>

<file context>
@@ -1,274 +1,75 @@
+    mocker.patch("reflex.utils.export.prerequisites")
+    mocker.patch("reflex.utils.export.build")
+    mocker.patch("reflex.utils.export.exec")
+    mocker.patch("reflex.utils.export.console")
+    mocker.patch("reflex.utils.export.telemetry")
+    return mocker
</file context>
Suggested change
mocker.patch("reflex.utils.export.console")
mocker.patch("reflex.utils.export.console.rule")

Comment thread news/7947.bugfix.md
@@ -0,0 +1 @@
Fixed console log level not being restored after `reflex export` completes, which caused `reflex deploy` to hide progress messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Towncrier will ignore this fragment because root release notes are read from news/, not changes/; move it to news/7947.bugfix.md so the fix is included in the changelog.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At changes/7947.bugfix.md, line 1:

<comment>Towncrier will ignore this fragment because root release notes are read from `news/`, not `changes/`; move it to `news/7947.bugfix.md` so the fix is included in the changelog.</comment>

<file context>
@@ -0,0 +1 @@
+Fixed console log level not being restored after `reflex export` completes, which caused `reflex deploy` to hide progress messages.

</file context>

@DevChiniwala
DevChiniwala force-pushed the fix/deploy-restore-loglevel branch from fe2e381 to e60e077 Compare November 20, 2026 23:26
Comment thread tests/units/utils/test_export.py Resolved
@DevChiniwala
DevChiniwala force-pushed the fix/deploy-restore-loglevel branch from e60e077 to 709d7f4 Compare November 20, 2026 23:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/units/utils/test_export.py">

<violation number="1" location="tests/units/utils/test_export.py:290">
P2: This test never reaches the configured `get_compiled_app` failure because `frontend=False` skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass `frontend=True` for this failure case.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

View guided diff | Re-trigger cubic

assert _log.get_log_level() == initial_level

# Call export with a different log level
export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: This test never reaches the configured get_compiled_app failure because frontend=False skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass frontend=True for this failure case.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/utils/test_export.py, line 290:

<comment>This test never reaches the configured `get_compiled_app` failure because `frontend=False` skips that phase, so it fails unconditionally instead of testing restoration on an exception. Pass `frontend=True` for this failure case.</comment>

<file context>
@@ -44,46 +287,40 @@ def test_export_restores_log_level_on_success(mock_export_dependencies):
 
     # Call export with a different log level
-    export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)
+    export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)
 
     # Verify log level was restored to initial level
</file context>
Suggested change
export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=False, backend=False)
export.export(loglevel=constants.LogLevel.DEBUG, zipping=False, frontend=True, backend=False)

Comment thread tests/units/utils/test_export.py Resolved
Comment thread tests/units/utils/test_export.py Resolved
@DevChiniwala
DevChiniwala force-pushed the fix/deploy-restore-loglevel branch 2 times, most recently from bb0ccaa to b41e1fb Compare November 21, 2026 12:02
The export() function sets the console to the subprocess log level
(WARNING by default) but never restores it, hiding all INFO messages
from callers like `reflex deploy` after the export step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DevChiniwala
DevChiniwala force-pushed the fix/deploy-restore-loglevel branch from b41e1fb to 9797836 Compare November 21, 2026 12:03
Comment on lines +311 to +312
initial_level = constants.LogLevel.WARNING
console.set_log_level(initial_level)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Tests leave logging settings behind

The new tests change the process-wide log level without restoring the level they found. The last test leaves _log_level and REFLEX_LOGLEVEL set to WARNING. The shared teardown calls _reset(), which restores neither value, so later tests and their subprocesses inherit this test's settings. Save and restore both values in a fixture.

This branch has not been deployed

No deployments
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.

reflex deploy hides its progress and success messages: the export step leaves the console at WARNING

2 participants