editor icon indicating copy to clipboard operation
editor copied to clipboard

Dev console spammed with 'THREE.Clock: This module has been deprecated' on every Canvas mount

Open kmjnnhyk opened this issue 7 months ago • 1 comments

What happened?

Every page load and HMR reload of the editor floods the editor#dev terminal (and the browser devtools console) with repeated THREE.Clock: This module has been deprecated. Please use THREE.Timer instead. warnings.

Root cause (verified):

  • three.js r183 marked THREE.Clock as @deprecated and added a warning inside its constructor (node_modules/three/build/three.core.js:55734).
  • We don't instantiate Clock anywhere in this repo (verified via grep -r "new THREE.Clock" packages apps).
  • @react-three/fiber 9.x — current stable, and our pinned version (apps/editor/package.json, packages/editor/package.json, packages/viewer/package.json all peer on ^0.183 and import R3F ^9) — still calls new THREE.Clock() internally per <Canvas> mount (node_modules/@react-three/fiber/dist/events-5a94e5eb.esm.js:972). So every Canvas mount re-triggers the warning.
  • Upstream is already aware and the migration to THREE.Timer is done in R3F v10: see pmndrs/react-three-fiber#2688 ("v10: Proposal to revamp the frameloop"), closed with maintainer comment "Done with scheduler in v10" (2026-01-08). However R3F v10 is still alpha (10.0.0-alpha.2 latest as of filing) so we can't upgrade out of the problem.

Steps to reproduce

  1. bun dev
  2. Open http://localhost:3002
  3. Observe the editor#dev task panel — every request and every HMR reload prints lines like:
    [browser] THREE.THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.
     GET / 200 in 143ms (next.js: 40ms, application-code: 103ms)
    [browser] THREE.THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.
    
  4. The same warning also appears in the browser devtools console.

Expected behavior

The editor dev console should not be flooded with deprecation warnings that originate from a transitive dependency we can't upgrade. At minimum the signal-to-noise ratio should stay usable so that real warnings and errors don't get drowned out.

Browser & OS

Chrome / macOS (reproduces in any browser since the warning is emitted from three.js code running client-side)

Additional context

Upstream tracking:

  • pmndrs/react-three-fiber#2688 — v10 frameloop revamp that replaces THREE.Clock with Timer. Closed, done in v10 branch. This is the fix we are waiting on.
  • R3F v10 stable release is the cleanest resolution — when it ships and we bump, the warning disappears without any code changes on our side.

Possible interim options (all tradeoffs, no free lunch):

  1. Wait for R3F v10 stable — zero code, zero risk, unknown timeline.
  2. Upgrade to @react-three/[email protected] now — fixes it immediately but pulls in unreleased code; likely brings other breaking changes and instability.
  3. Pin three.js to 0.182.x across all workspaces — silences the warning because r182 doesn't have the deprecation line, but loses r183 fixes and creates a ceiling on other three-consuming deps.
  4. Local shim via three's setConsoleFunction hook — filter just this one message. Prototyped in #212 (now closed) with all the design notes. Leaves a transitional file in the repo that has to be deleted once R3F 10 lands.

Recommendation: default to option 1 (wait). If the noise becomes actively disruptive before R3F 10 ships stable, revisit option 4 — the prototype in #212 has a self-documenting removal condition (grep node_modules/@react-three/fiber/dist for "new THREE.Clock") and the full design review is already in the PR history.

Verification commands for whoever picks this up:

# Confirm our code is clean
grep -rn "new THREE.Clock\|new Clock(" packages apps

# Confirm R3F is still the source
grep -n "new THREE.Clock" node_modules/@react-three/fiber/dist/*.js

# Check latest R3F versions
npm view @react-three/fiber dist-tags

kmjnnhyk avatar Apr 05 '26 15:04 kmjnnhyk

Thanks for the thorough investigation and the prototype in #212 — this was really well done.

We've opened #215 which implements option 4 from your analysis: a surgical setConsoleFunction hook that suppresses only the exact Clock deprecation message while passing everything else through untouched. The implementation follows the same approach you prototyped, with exact-string matching, HMR idempotency, and stack-trace passthrough.

This will hold us over until R3F v10 stable ships and we can upgrade properly. The file has a documented removal condition so it won't get forgotten.

Appreciate you taking the time to research and document all the options — it made the decision straightforward.

open-pascal avatar Apr 06 '26 13:04 open-pascal