Skip to content

fix(composables): Correct inverted logic in version check causing infinite loop thus OOM#421

Merged
nekomeowww merged 1 commit intomoeru-ai:mainfrom
skirkru:0.7.2-oom
Aug 24, 2025
Merged

fix(composables): Correct inverted logic in version check causing infinite loop thus OOM#421
nekomeowww merged 1 commit intomoeru-ai:mainfrom
skirkru:0.7.2-oom

Conversation

@skirkru
Copy link
Contributor

@skirkru skirkru commented Aug 24, 2025

Description

Fixed Memory Leak by Endless Loop, Fix #414, #375, #400

Summary

This commit resolves a critical bug that caused the application to crash due to an infinite recursive update loop. The issue originated in the useVersionedLocalStorage composable, where the version validation logic was incorrectly implemented.

Problem

The satisfiesVersionBy function was configured with an inverted condition (v !== '1.0.2'). This logic incorrectly identified the current, valid data version as incompatible. As a result, the onVersionMismatch handler was perpetually triggered, leading to a continuous cycle of data resets and component updates that ultimately exceeded Vue's maximum recursion depth and crashed the application.

Solution

The logical condition in the satisfiesVersionBy function has been corrected to `v === '1.0.2'. This ensures that the stored data's version is properly validated, preventing the erroneous triggering of the data reset mechanism and resolving the infinite loop.

My Comment

I thought this was a Tauri fault, but it turned out to be a silly mistake.

…inite loop thus OOM

Corrects the `satisfiesVersionBy` logic in the `useVersionedLocalStorage` composable. The previous implementation (`v !== '1.0.2'`) was inverted, causing it to return `false` for the valid version. This triggered the `onVersionMismatch` handler, which reset the data, re-triggered the `watch` effect, and resulted in an infinite recursive update loop, crashing the application.

The condition has been changed to `v === '1.0.2' to correctly validate the version and prevent the loop.

I though this is tauri fault, but kek just silly mistake

Fix moeru-ai#414 moeru-ai#375 moeru-ai#400
@netlify
Copy link

netlify bot commented Aug 24, 2025

Deploy Preview for airi-docs ready!

Name Link
🔨 Latest commit 544b3ef
🔍 Latest deploy log https://app.netlify.com/projects/airi-docs/deploys/68aab951695d8b00082cc007
😎 Deploy Preview https://deploy-preview-421--airi-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Aug 24, 2025

Deploy Preview for airi-vtuber ready!

Name Link
🔨 Latest commit 544b3ef
🔍 Latest deploy log https://app.netlify.com/projects/airi-vtuber/deploys/68aab951d698ed0008a13c06
😎 Deploy Preview https://deploy-preview-421--airi-vtuber.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @skirkru, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug that caused the application to crash due to an infinite recursive update loop. The issue stemmed from an incorrectly implemented version validation logic within the useVersionedLocalStorage composable. By correcting an inverted condition, the change ensures proper data version validation, preventing continuous data resets and stabilizing the application.

Highlights

  • Bug Fix: Infinite Loop and OOM: Addresses a critical bug where an inverted version validation logic in useVersionedLocalStorage led to an infinite recursive update loop, causing out-of-memory errors and application crashes.
  • Logic Correction: Corrected the satisfiesVersionBy function from v !== '1.0.2' to v === '1.0.2', ensuring proper validation of stored data versions.
  • Impact: Prevents erroneous triggering of data resets and resolves the continuous cycle of updates, stabilizing the application.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves a critical bug that was causing an infinite loop and subsequent memory exhaustion. The fix, which corrects the inverted logic in the satisfiesVersionBy version check, is accurate and directly addresses the root cause described. My review includes a suggestion to refactor the duplicated versioning configuration to improve long-term maintainability, which can be handled in a follow-up.

{
name: 'tamagotchi.settings.pages.themes.window-shortcuts.toggle-move.label',
shortcut: useVersionedLocalStorage('shortcuts/window/move', 'Shift+Alt+N', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v !== '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + N
shortcut: useVersionedLocalStorage('shortcuts/window/move', 'Shift+Alt+N', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v === '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + N
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly fixes the critical infinite loop bug. Well done for spotting the inverted logic!

For future maintainability, you might consider refactoring the duplicated versioning options. The object { defaultVersion: '1.0.2', satisfiesVersionBy: v => v === '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) } is repeated for each shortcut.

You could extract this to a constant at the top of the defineStore callback:

const shortcutVersionOptions = {
  defaultVersion: '1.0.2',
  satisfiesVersionBy: (v: string) => v === '1.0.2',
  onVersionMismatch: () => ({ action: 'reset' as const }),
};

And then reuse it for each shortcut:

shortcut: useVersionedLocalStorage('shortcuts/window/move', 'Shift+Alt+N', shortcutVersionOptions),

This would make it easier to update the versioning logic in one place in the future. Since this is a broader refactoring that affects lines outside the current changes, it can be addressed in a follow-up PR.

@nekomeowww
Copy link
Member

Already improved from 21b3307 with universal model selector.

@nekomeowww nekomeowww closed this Aug 24, 2025
@nekomeowww nekomeowww reopened this Aug 24, 2025
@nekomeowww
Copy link
Member

Oh sorry I misunderstood this Pull Request. Indeed helpful, thanks.

@nekomeowww nekomeowww merged commit 8ea9803 into moeru-ai:main Aug 24, 2025
8 checks passed
@skirkru
Copy link
Contributor Author

skirkru commented Aug 24, 2025

@nekomeowww I checked your commit 21b3307, that does not solve the issue

@skirkru
Copy link
Contributor Author

skirkru commented Aug 24, 2025

Oh lol, that comment up when I typing

Disqort pushed a commit to Disqort/airi that referenced this pull request Aug 29, 2025
…inite loop thus OOM (moeru-ai#421)

Corrects the `satisfiesVersionBy` logic in the `useVersionedLocalStorage` composable. The previous implementation (`v !== '1.0.2'`) was inverted, causing it to return `false` for the valid version. This triggered the `onVersionMismatch` handler, which reset the data, re-triggered the `watch` effect, and resulted in an infinite recursive update loop, crashing the application.

The condition has been changed to `v === '1.0.2' to correctly validate the version and prevent the loop.

I though this is tauri fault, but kek just silly mistake

Fix moeru-ai#414 moeru-ai#375 moeru-ai#400
lucas-oma pushed a commit to lucas-oma/airi that referenced this pull request Sep 7, 2025
…inite loop thus OOM (moeru-ai#421)

Corrects the `satisfiesVersionBy` logic in the `useVersionedLocalStorage` composable. The previous implementation (`v !== '1.0.2'`) was inverted, causing it to return `false` for the valid version. This triggered the `onVersionMismatch` handler, which reset the data, re-triggered the `watch` effect, and resulted in an infinite recursive update loop, crashing the application.

The condition has been changed to `v === '1.0.2' to correctly validate the version and prevent the loop.

I though this is tauri fault, but kek just silly mistake

Fix moeru-ai#414 moeru-ai#375 moeru-ai#400
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.

[Bug] Desktop app crashes with "Maximum recursive updates exceeded"

2 participants