Skip to content

fix: improve performance - #211

Merged
Exeloo merged 2 commits into
fix/improve-accessibilityfrom
fix/improve-performance
Nov 5, 2026
Merged

Exeloo merged 2 commits into
fix/improve-accessibilityfrom
fix/improve-performance

Conversation

@Exeloo

@Exeloo Exeloo commented Oct 30, 2026

Copy link
Copy Markdown
Member

What does this PR do?

The PR improve the performance of the app by compresse and minify plugins.

How do you test this PR?

@Exeloo
Exeloo requested a review from Tchips46 as a code owner October 30, 2026 09:28
@github-actions github-actions Bot added documentation Improvements or additions to documentation apps:editor Related to Editor app packages:code Related to Code package packages:server-core Related to Server core package plugins:code-editor Related to Code editor plugin plugins:ecs Related to ECS plugin tooling:vite-plugin Related to Vite plugin tooling labels Oct 30, 2026
@Exeloo
Exeloo added this pull request to stack #212 October 30, 2026 09:29

@Tchips46 Tchips46 left a comment

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.

Review: performance (209ef4a)

Line numbers are at this PR's head. The compression part looks sound: Vary is set, the cache key includes size and mtime, and no new path handling was added. The findings are in the code-service changes, which the PR body doesn't mention.

Should fix

1. The incremental Problems check loses changes recorded while it waits (packages/code/src/service/code-service.ts:410-414)

  • It copies changed, awaits _declaresGlobally(changed) (file reads), and only then sets _fullCheck = false and clears _changedSinceCheck.
  • Anything recorded during that await is wiped, including a _fullCheck = true from a file create or delete. Example: "Add component" creates components/armor.ts during a check, and main.ts keeps "Cannot find module './components/armor'" until some later full check.
  • Fix: read and reset both fields before the first await: const wasFull = this._fullCheck; this._fullCheck = false; this._changedSinceCheck.clear(); const full = wasFull || await this._declaresGlobally(changed);

2. forgetMissingTypes never reloads a package that another app already found (packages/code/src/engine/code-engine.ts:229-232, _loadTypes at 390-399)

  • It deletes _typeRoots only when !roots.found.length, but asked is per folder and found is shared across apps.
  • Example: client and server each have their own node_modules, and the client has @nanoforge-dev/ecs while the server has no dependencies yet. After pnpm i in the server, nothing is cleared, and the server's 2307 errors stay.
  • Fix: for packages in _missing, call roots.asked.clear().

3. TypeLibraries keeps loading the old project after dispose (plugins/code-editor/src/typing/type-libraries.ts:86-100, 116-121)

  • The new 8-wide queue goes through every code file, and _load → _add → addExtraLib keeps running after dispose(), which runs on a project switch.
  • Example: switch projects during the first load of a large project. The rest of the old project is added as extra libs that nothing disposes, under file:///apps/client/src/... paths that clash with the new project's files.
  • Fix: a _disposed flag, checked in the queue loop and after the await in _load.

4. Meta cache writes can fail unhandled, and are never retried (packages/code/src/catalog/meta-cache.ts:56, 63, 82-98)

  • _ensureIgnored's readText has no catch, and _doWrite runs fire-and-forget. Before this PR, the same code ran under _run's try/catch.
  • _written.set (line 87) runs before the write, so after a failure, every later write of the same text is skipped for the rest of the session.
  • Example: the project closes, or the server goes away, while a write is pending.
  • Fix: in _write, .catch((e) => { this._written.delete(path); logger.warn(...) }).

Nice to have

  • pickEncoding (packages/server-core/src/http/compressed-files.ts:21) treats only the literal q=0 as a refusal, so br;q=0.0 gets Brotli. Fix: parseFloat(...) === 0.
  • lib.entry (tooling/vite-plugin/src/plugin/nanoforge-editor-plugin.ts:38): echoing the user's own value back makes Vite's mergeConfig concatenate arrays, the same bug this PR fixes for formats. entry: ['src/index.ts'] ends up twice. Fix: set entry only when lib?.entry is undefined.
  • Dev watch builds (same file, line 44) are now minified with no source map, so stack traces from hot-reloaded dev plugins become index.js:1:NNNNN. Fix: && !user.build?.watch.
  • Not checked: the vite-plugin's peer range allows Vite 7. If Vite 7's config hook has no this.meta, 'rolldownVersion' in this.meta throws. A this?.meta && guard is cheap.

@Exeloo
Exeloo force-pushed the fix/improve-performance branch from 209ef4a to b89deb0 Compare November 1, 2026 13:21
- code: keep changes recorded while a check reads what changed
- code: ask again for types an app lacked once dependencies change
- code: a meta cache write survives an unreadable .gitignore
- code-editor: type libraries stop loading once disposed
- server-core: any zero quality refuses an encoding
- vite-plugin: keep the user's lib entry, no minify in watch builds
@Exeloo
Exeloo force-pushed the fix/improve-performance branch from b89deb0 to 7422db3 Compare November 5, 2026 11:55
@Exeloo
Exeloo merged commit 5f11200 into main Nov 5, 2026
8 checks passed
@Exeloo
Exeloo deleted the fix/improve-performance branch November 5, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps:editor Related to Editor app documentation Improvements or additions to documentation packages:code Related to Code package packages:server-core Related to Server core package plugins:code-editor Related to Code editor plugin plugins:ecs Related to ECS plugin tooling:vite-plugin Related to Vite plugin tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants