nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] The update check posts a red error into the chat on every offline launch, has no throttle, and cannot be turned off

Open addyCooks opened this issue 1 month ago • 1 comments

Description

Every start calls checkForUpdates() (source/hooks/useAppInitialization.tsx:703). When the request fails (offline, slow network), fetchLatestVersion posts Failed to fetch latest version: ... into the chat as an error (source/utils/update-checker.ts:77). The check also has no throttle and no way to turn it off. lastUpdateCheck is written (update-checker.ts:87) but never read, even though docs/configuration/preferences.md:54 says it is "used to avoid checking too frequently". For a local-first tool that is often used offline, this means a red error on each launch and a request to the npm registry every time.

Environment

  • OS: Windows 11 (10.0.26300)
  • Node version: 22.22.3
  • Nanocoder version: 1.31.0 (main at 9d88dda7)
  • Provider / Model: not relevant

Steps to Reproduce

  1. Disconnect from the network (or block registry.npmjs.org) and start nanocoder.
  2. Start it again.
  3. While online, start it twice within a few seconds and count the requests to the registry.
  4. Search the code for a reader of lastUpdateCheck and for an option to disable the check.

Expected Behavior

  • A failed check does not put an error in the chat (log it to the file log only).
  • A check that succeeded recently is not repeated (for example once every 24 hours).
  • There is a way to turn the check off (a preference or NANOCODER_NO_UPDATE_CHECK).

Actual Behavior

Running the real checkForUpdates with a fake offline network and a captured chat queue:

OFFLINE launch     -> messages posted into the chat: ["Failed to fetch latest version: The operation was aborted due to timeout"]
                      lastUpdateCheck saved: (never)
OFFLINE 2nd launch -> registry requests so far: 2 | chat messages: 2
ONLINE             -> lastUpdateCheck saved: 1791888811330 | registry requests for 2 launches within a second: 2

The only places lastUpdateCheck appears are its type (source/types/config.ts:691) and the write. There is no setting or variable that disables the check.

Suggested Fix

  • In fetchLatestVersion (update-checker.ts:70-79), log failures with the file logger instead of logError.
  • At the top of checkForUpdates, return early if lastUpdateCheck is newer than 24 hours.
  • Add an opt-out (a preference and/or NANOCODER_NO_UPDATE_CHECK=1) and document it.
  • Add tests for the three points above.

Additional Context

  • Related: #1468 (same message, JSON-parse cause, open), #739 and PR #741 (closed; they fixed the timestamp being written after a failed fetch).
  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder

addyCooks avatar Oct 13 '26 12:10 addyCooks

Hi, I would like to take this issue. I plan to add the documented 24-hour successful-check cooldown, keep fetch failures out of the chat UI while retaining useful diagnostics, and provide an explicit opt-out with regression tests. I will open a PR after verifying the behavior; if you prefer a configuration setting over an environment variable for opt-out, please let me know.

ducanhnguyen223 avatar Oct 13 '26 23:10 ducanhnguyen223