Skip to content

[progress] Show runtime errors only once#48591

Open
silviuaavram wants to merge 5 commits into
mui:masterfrom
silviuaavram:fix/show-progress-warnings-once
Open

[progress] Show runtime errors only once#48591
silviuaavram wants to merge 5 commits into
mui:masterfrom
silviuaavram:fix/show-progress-warnings-once

Conversation

@silviuaavram
Copy link
Copy Markdown
Member

@silviuaavram silviuaavram commented May 29, 2026

Fixes #48562.

Copilot AI review requested due to automatic review settings May 29, 2026 09:13
@silviuaavram silviuaavram added the scope: progress Changes related to the progress. label May 29, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 29, 2026

Deploy preview

https://deploy-preview-48591--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new errorOnce utility in @mui/utils and adopts it in LinearProgress and CircularProgress to avoid repeating the same dev-time warnings/errors across renders (notably in React Strict Mode), addressing console spam reported for progress components.

Changes:

  • Add @mui/utils/errorOnce (with reset support) and export it from @mui/utils.
  • Replace repeated console.warn/console.error calls in LinearProgress and CircularProgress with errorOnce.
  • Update component tests to reset the errorOnce cache and to assert single-emission logging behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/mui-utils/src/index.ts Exports the new errorOnce utility (and its reset alias) from the root utils entrypoint.
packages/mui-utils/src/errorOnce/index.ts Adds the subpath entrypoint for @mui/utils/errorOnce.
packages/mui-utils/src/errorOnce/errorOnce.ts Implements dev-only “log once” behavior with an optional key and a reset function.
packages/mui-utils/src/errorOnce/errorOnce.test.ts Adds unit tests for errorOnce behavior and reset semantics.
packages/mui-material/src/LinearProgress/LinearProgress.js Uses errorOnce to dedupe dev warnings/errors for invalid props.
packages/mui-material/src/LinearProgress/LinearProgress.test.js Updates expectations for deduped logs and resets cache between cases.
packages/mui-material/src/CircularProgress/CircularProgress.js Uses errorOnce to dedupe dev warnings/errors for invalid props.
packages/mui-material/src/CircularProgress/CircularProgress.test.js Updates expectations for deduped logs and resets cache between cases.
Comments suppressed due to low confidence (4)

packages/mui-material/src/LinearProgress/LinearProgress.test.js:7

  • strictModeDoubleLoggingSuppressed is imported but no longer used in this test file. This will fail lint/type-check (unused import) and should be removed.
import {
  createRenderer,
  screen,
  strictModeDoubleLoggingSuppressed,
} from '@mui/internal-test-utils';

packages/mui-material/src/CircularProgress/CircularProgress.test.js:7

  • strictModeDoubleLoggingSuppressed is imported but no longer used in this test file. This will fail lint/type-check (unused import) and should be removed.
import {
  createRenderer,
  strictModeDoubleLoggingSuppressed,
  screen,
} from '@mui/internal-test-utils';

packages/mui-material/src/LinearProgress/LinearProgress.test.js:7

  • strictModeDoubleLoggingSuppressed is imported but no longer used in this test file. This will fail lint/type-check (unused import) and should be removed.
import {
  createRenderer,
  screen,
  strictModeDoubleLoggingSuppressed,
} from '@mui/internal-test-utils';

packages/mui-material/src/CircularProgress/CircularProgress.test.js:7

  • strictModeDoubleLoggingSuppressed is imported but no longer used in this test file. This will fail lint/type-check (unused import) and should be removed.
import {
  createRenderer,
  strictModeDoubleLoggingSuppressed,
  screen,
} from '@mui/internal-test-utils';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-utils/src/errorOnce/errorOnce.test.ts Outdated
Comment thread packages/mui-material/src/CircularProgress/CircularProgress.js Outdated
Comment thread packages/mui-material/src/LinearProgress/LinearProgress.js Outdated
);
}
}
errorOnce(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moving the NODE_ENV check would cause a bit more work here as the logic to compute the arguments are no longer skipped since they are evaluated before errorOnce runs

Might be easier to keep the check at all the call sites?

Codex tried to pitch this alternative API to avoid this issue but I'm not convinced:

function errorOnce(
  key: string,
  level: ErrorOnceLevel,
  getMessage: () => string | null | false,
) {
  ...
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

or maybe the message could be string | () => string. we might over-engineer this, let me see how it will look without the helper and do the checks on site.

@silviuaavram silviuaavram requested a review from siriwatknp May 29, 2026 12:37
@silviuaavram silviuaavram force-pushed the fix/show-progress-warnings-once branch from e7d9827 to 91a464a Compare May 29, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: progress Changes related to the progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[progress] Cyclical CircularProgress

3 participants