Skip to content

fix exceeding localstorage quota#943

Merged
hatemhosny merged 1 commit intodevelopfrom
fix-exceeding-localstorage
Feb 11, 2026
Merged

fix exceeding localstorage quota#943
hatemhosny merged 1 commit intodevelopfrom
fix-exceeding-localstorage

Conversation

@hatemhosny
Copy link
Collaborator

@hatemhosny hatemhosny commented Feb 11, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for data storage operations to prevent application crashes when storage quota is exceeded. The app now gracefully manages these scenarios, maintaining stability and ensuring uninterrupted functionality.

@netlify
Copy link

netlify bot commented Feb 11, 2026

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit 3e5f03c
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/698bc8c243a932000885d9f2
😎 Deploy Preview https://deploy-preview-943--livecodes.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.

@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

Size Change: +73 B (+0.01%)

Total Size: 1.02 MB

ℹ️ View Unchanged
Filename Size Change
./build/404.html 1 kB 0 B
./build/app.html 250 B 0 B
./build/index.html 2.46 kB +1 B (+0.04%)
./build/livecodes/app.css 22.5 kB 0 B
./build/livecodes/app.js 112 kB +63 B (+0.06%)
./build/livecodes/assets.js 8.6 kB 0 B
./build/livecodes/assets/noop.js 18 B 0 B
./build/livecodes/assets/templates/diagrams-starter.html 2.19 kB 0 B
./build/livecodes/backup.js 3.73 kB +16 B (+0.43%)
./build/livecodes/blockly.js 13.4 kB 0 B
./build/livecodes/broadcast.js 1.19 kB 0 B
./build/livecodes/bundle-types.js 4.36 kB 0 B
./build/livecodes/code-to-image.js 9.09 kB -20 B (-0.22%)
./build/livecodes/codejar.js 17.6 kB 0 B
./build/livecodes/codemirror.js 6.29 kB 0 B
./build/livecodes/compile.page.js 2.4 kB 0 B
./build/livecodes/compile.worker.js 14.5 kB 0 B
./build/livecodes/compiler-utils.js 3.16 kB 0 B
./build/livecodes/custom-editor-utils.js 198 B 0 B
./build/livecodes/deploy.js 6.89 kB +18 B (+0.26%)
./build/livecodes/editor-settings.js 17.7 kB -18 B (-0.1%)
./build/livecodes/embed-ui.js 5.53 kB +1 B (+0.02%)
./build/livecodes/embed.js 90 kB +128 B (+0.14%)
./build/livecodes/export.js 3.89 kB 0 B
./build/livecodes/firebase.js 22.7 kB 0 B
./build/livecodes/format.worker.js 13.5 kB 0 B
./build/livecodes/google-fonts.js 7.12 kB 0 B
./build/livecodes/headless.js 78.6 kB -30 B (-0.04%)
./build/livecodes/i18n-ar-language-info.json 5.34 kB 0 B
./build/livecodes/i18n-ar-translation.json 9.32 kB 0 B
./build/livecodes/i18n-bn-language-info.json 5.76 kB 0 B
./build/livecodes/i18n-bn-translation.json 9.66 kB 0 B
./build/livecodes/i18n-de-language-info.json 5.4 kB 0 B
./build/livecodes/i18n-de-translation.json 9.45 kB 0 B
./build/livecodes/i18n-en-language-info.json 4.63 kB 0 B
./build/livecodes/i18n-en-translation.json 8.04 kB 0 B
./build/livecodes/i18n-es-language-info.json 5.12 kB 0 B
./build/livecodes/i18n-es-translation.json 9.18 kB 0 B
./build/livecodes/i18n-fa-language-info.json 5.52 kB 0 B
./build/livecodes/i18n-fa-translation.json 9.47 kB 0 B
./build/livecodes/i18n-fr-language-info.json 5.31 kB 0 B
./build/livecodes/i18n-fr-translation.json 9.42 kB 0 B
./build/livecodes/i18n-hi-language-info.json 5.93 kB 0 B
./build/livecodes/i18n-hi-translation.json 9.97 kB 0 B
./build/livecodes/i18n-id-language-info.json 4.87 kB 0 B
./build/livecodes/i18n-id-translation.json 8.7 kB 0 B
./build/livecodes/i18n-it-language-info.json 5.17 kB 0 B
./build/livecodes/i18n-it-translation.json 9.25 kB 0 B
./build/livecodes/i18n-ja-language-info.json 5.72 kB 0 B
./build/livecodes/i18n-ja-translation.json 9.62 kB 0 B
./build/livecodes/i18n-nl-language-info.json 5.07 kB 0 B
./build/livecodes/i18n-nl-translation.json 8.9 kB 0 B
./build/livecodes/i18n-pt-language-info.json 5.16 kB 0 B
./build/livecodes/i18n-pt-translation.json 9.37 kB 0 B
./build/livecodes/i18n-ru-language-info.json 5.7 kB 0 B
./build/livecodes/i18n-ru-translation.json 10.3 kB 0 B
./build/livecodes/i18n-tr-language-info.json 5.3 kB 0 B
./build/livecodes/i18n-tr-translation.json 9.27 kB 0 B
./build/livecodes/i18n-ur-language-info.json 5.97 kB 0 B
./build/livecodes/i18n-ur-translation.json 9.8 kB 0 B
./build/livecodes/i18n-zh-CN-language-info.json 5.01 kB 0 B
./build/livecodes/i18n-zh-CN-translation.json 8.66 kB 0 B
./build/livecodes/i18n.js 20.3 kB -30 B (-0.15%)
./build/livecodes/import-src.js 16.2 kB 0 B
./build/livecodes/import.js 14.6 kB -55 B (-0.38%)
./build/livecodes/index.js 5.35 kB -23 B (-0.43%)
./build/livecodes/lang-art-template-compiler.js 1.65 kB 0 B
./build/livecodes/lang-assemblyscript-compiler.js 290 B 0 B
./build/livecodes/lang-assemblyscript-script.js 386 B 0 B
./build/livecodes/lang-astro-compiler.js 2.34 kB 0 B
./build/livecodes/lang-clio-compiler.js 1.55 kB 0 B
./build/livecodes/lang-commonlisp-script.js 123 B 0 B
./build/livecodes/lang-cpp-script.js 1.74 kB 0 B
./build/livecodes/lang-cpp-wasm-script.js 2.84 kB 0 B
./build/livecodes/lang-csharp-wasm-script.js 2.18 kB 0 B
./build/livecodes/lang-diagrams-compiler-esm.js 5.09 kB 0 B
./build/livecodes/lang-dot-compiler.js 1.66 kB 0 B
./build/livecodes/lang-ejs-compiler.js 1.63 kB 0 B
./build/livecodes/lang-eta-compiler.js 1.65 kB 0 B
./build/livecodes/lang-fennel-compiler.js 1.61 kB 0 B
./build/livecodes/lang-gleam-compiler.js 3.09 kB 0 B
./build/livecodes/lang-go-wasm-script.js 3.25 kB 0 B
./build/livecodes/lang-haml-compiler.js 1.65 kB 0 B
./build/livecodes/lang-handlebars-compiler.js 1.95 kB 0 B
./build/livecodes/lang-imba-compiler.js 147 B 0 B
./build/livecodes/lang-java-script.js 4.05 kB 0 B
./build/livecodes/lang-jinja-compiler.js 1.65 kB 0 B
./build/livecodes/lang-julia-script.js 3.31 kB 0 B
./build/livecodes/lang-liquid-compiler.js 1.68 kB 0 B
./build/livecodes/lang-lua-wasm-script.js 205 B 0 B
./build/livecodes/lang-malina-compiler.js 2.96 kB 0 B
./build/livecodes/lang-minizinc-script.js 2.06 kB 0 B
./build/livecodes/lang-mustache-compiler.js 1.65 kB 0 B
./build/livecodes/lang-nunjucks-compiler.js 1.96 kB 0 B
./build/livecodes/lang-perl-script.js 268 B 0 B
./build/livecodes/lang-php-wasm-script.js 347 B 0 B
./build/livecodes/lang-postgresql-compiler-esm.js 1.73 kB 0 B
./build/livecodes/lang-prolog-script.js 204 B 0 B
./build/livecodes/lang-pug-compiler.js 371 B 0 B
./build/livecodes/lang-python-wasm-script.js 1.86 kB 0 B
./build/livecodes/lang-r-script-esm.js 2.44 kB 0 B
./build/livecodes/lang-rescript-compiler-esm.js 2.16 kB 0 B
./build/livecodes/lang-rescript-formatter.js 1.52 kB 0 B
./build/livecodes/lang-riot-compiler.js 2.81 kB 0 B
./build/livecodes/lang-ruby-wasm-script.js 1.71 kB 0 B
./build/livecodes/lang-scss-compiler.js 1.71 kB 0 B
./build/livecodes/lang-solid-compiler.js 263 B 0 B
./build/livecodes/lang-sql-compiler.js 1.64 kB 0 B
./build/livecodes/lang-sql-script.js 1.95 kB 0 B
./build/livecodes/lang-svelte-compiler.js 4.69 kB 0 B
./build/livecodes/lang-tcl-script.js 1.82 kB 0 B
./build/livecodes/lang-teal-compiler.js 1.72 kB 0 B
./build/livecodes/lang-twig-compiler.js 1.64 kB 0 B
./build/livecodes/lang-vento-compiler.js 1.68 kB 0 B
./build/livecodes/lang-vue-compiler.js 6.09 kB 0 B
./build/livecodes/lang-vue2-compiler.js 3.48 kB 0 B
./build/livecodes/lang-wat-compiler.js 348 B 0 B
./build/livecodes/lang-wat-script.js 1.58 kB 0 B
./build/livecodes/language-info.js 7.92 kB +6 B (+0.08%)
./build/livecodes/monaco-lang-astro.js 947 B 0 B
./build/livecodes/monaco-lang-clio.js 639 B 0 B
./build/livecodes/monaco-lang-imba.js 7.35 kB 0 B
./build/livecodes/monaco-lang-minizinc.js 1.74 kB 0 B
./build/livecodes/monaco-lang-prolog.js 580 B 0 B
./build/livecodes/monaco-lang-wat.js 2.46 kB 0 B
./build/livecodes/monaco.js 10.1 kB 0 B
./build/livecodes/open.js 6.21 kB +6 B (+0.1%)
./build/livecodes/processor-lightningcss-compiler.js 1.88 kB 0 B
./build/livecodes/processor-postcss-compiler.js 2.02 kB 0 B
./build/livecodes/processor-tailwindcss-compiler.js 5.24 kB 0 B
./build/livecodes/processor-unocss-compiler.js 355 B 0 B
./build/livecodes/processor-windicss-compiler.js 450 B 0 B
./build/livecodes/quill.css 697 B 0 B
./build/livecodes/quill.js 5.8 kB 0 B
./build/livecodes/resources.js 3.43 kB -1 B (-0.03%)
./build/livecodes/result-utils.js 1.17 kB 0 B
./build/livecodes/share.js 3.81 kB 0 B
./build/livecodes/snippets.js 6.04 kB -3 B (-0.05%)
./build/livecodes/sync-ui.js 3.25 kB -11 B (-0.34%)
./build/livecodes/sync.js 3.54 kB +20 B (+0.57%)
./build/livecodes/sync.worker.js 29.7 kB +5 B (+0.02%)
./build/livecodes/templates.js 26.6 kB 0 B
./build/sdk/livecodes.js 3.95 kB 0 B
./build/sdk/livecodes.umd.js 4.02 kB 0 B
./build/sdk/package.json 292 B 0 B
./build/sdk/react.js 4.24 kB 0 B
./build/sdk/vue.js 4.36 kB 0 B

compressed-size-action

@cloudflare-workers-and-pages
Copy link

Deploying livecodes with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e5f03c
Status: ✅  Deploy successful!
Preview URL: https://a9ab4fbc.livecodes.pages.dev
Branch Preview URL: https://fix-exceeding-localstorage.livecodes.pages.dev

View logs

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Walkthrough

Error handling was added to the setValue method in the simple-storage module to wrap localStorage.setItem and notification publisher calls in a try/catch block, preventing operations from failing when localStorage quota is exceeded.

Changes

Cohort / File(s) Summary
Storage Error Handling
src/livecodes/storage/simple-storage.ts
Added try/catch wrapper around localStorage write and notification publisher invocations in the setValue method to gracefully handle quota exceeded errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix exceeding localstorage quota' directly and clearly describes the main change: adding error handling when localStorage quota is exceeded.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-exceeding-localstorage

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/livecodes/storage/simple-storage.ts`:
- Around line 25-30: The try/catch around window.localStorage.setItem(name,
JSON.stringify(value)) in simple-storage.ts currently swallows all errors;
narrow it to only handle storage-quota/security cases and surface others: catch
DOMException/QuotaExceededError (or check err.name/err.code) and in that branch
call notifyPub() as appropriate and emit a console.warn (or trigger a user
notification) with the error and the key name, but rethrow or propagate
non-quota errors (e.g., JSON.stringify TypeError) so bugs are not hidden;
reference the setItem call, the surrounding try/catch, and notifyPub to locate
where to implement this change.
🧹 Nitpick comments (1)
src/livecodes/storage/simple-storage.ts (1)

43-46: clear double-notifies subscribers on success.

setValue(null) already calls notifyPub() internally (line 27), so the explicit notifyPub() on line 45 triggers a second notification. This is pre-existing, but worth cleaning up — either remove line 45 or have clear use localStorage.setItem directly.

Proposed fix
   const clear = () => {
     setValue(null);
-    notifyPub();
   };

Comment on lines +25 to +30
try {
window.localStorage.setItem(name, JSON.stringify(value));
notifyPub();
} catch {
// exceeded quota
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Silent catch swallows all errors, risking unnoticed data loss.

Two concerns:

  1. No user/developer feedback — if a write silently fails, the user may lose data (e.g. settings, unsaved state) with no indication. Consider at least a console.warn so it's debuggable, and ideally surfacing a notification to the user.

  2. Overly broad catch — this catches every exception (e.g., SecurityError when storage is disabled, TypeError from JSON.stringify on circular refs), not just QuotaExceededError. Non-quota errors likely indicate bugs worth surfacing.

Proposed fix: narrow the catch and add minimal logging
   const setValue = (value: T | null) => {
     try {
       window.localStorage.setItem(name, JSON.stringify(value));
       notifyPub();
     } catch {
-      // exceeded quota
+    } catch (e) {
+      if (e instanceof DOMException && e.name === 'QuotaExceededError') {
+        console.warn(`[simple-storage] localStorage quota exceeded for "${name}"`);
+      } else {
+        throw e;
+      }
     }
   };
🤖 Prompt for AI Agents
In `@src/livecodes/storage/simple-storage.ts` around lines 25 - 30, The try/catch
around window.localStorage.setItem(name, JSON.stringify(value)) in
simple-storage.ts currently swallows all errors; narrow it to only handle
storage-quota/security cases and surface others: catch
DOMException/QuotaExceededError (or check err.name/err.code) and in that branch
call notifyPub() as appropriate and emit a console.warn (or trigger a user
notification) with the error and the key name, but rethrow or propagate
non-quota errors (e.g., JSON.stringify TypeError) so bugs are not hidden;
reference the setItem call, the surrounding try/catch, and notifyPub to locate
where to implement this change.

@hatemhosny hatemhosny merged commit 83d1eec into develop Feb 11, 2026
19 checks passed
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.

1 participant