Repository: OneKeyHQ/app-monorepo
Pull request #7390: Fix/ext storage check
Author: login: sidmorizon
Created: 2025-05-23T07:49:22Z | Merged: 2025-05-23T10:46:16Z



<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Improved browser extension compatibility by introducing polyfills for consistent API access across different environments.
  - Added a polyfill to ensure `requestAnimationFrame` is available in environments where it is missing.

- **Bug Fixes**
  - Enhanced reliability of disk space checks by preventing multiple overrides of the database transaction method.

- **Refactor**
  - Switched global object references from `globalThis` to `global` for greater environment compatibility.
  - Replaced external polyfill dependencies with local shim modules for improved maintainability.
  - Updated import order and code comments for better clarity and consistency.

- **Chores**
  - Introduced a named constant for disk space warning thresholds to improve code readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts b/packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts
new file mode 100644
index 000000000000..7c1842a4f38e
--- /dev/null
+++ b/packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts
@@ -0,0 +1,16 @@
+/* eslint-disable unicorn/prefer-global-this */
+import browser from 'webextension-polyfill'; // or extensionizer
+
+import platformEnv from '../../platformEnv';
+
+// TODO move to polyfill file
+if (platformEnv.isRuntimeFirefox) {
+  // @ts-ignore
+  browser.$$isPolyfill = true;
+  // @ts-ignore
+  global.chromeLegacy = global.chrome;
+  // @ts-ignore
+  global.chrome = browser;
+} else {
+  global.browser = global.browser || browser;
+}
diff --git a/packages/shared/src/polyfills/index.ts b/packages/shared/src/polyfills/index.ts
index 2e2db9de9b2f..415bbf9f14d9 100644
--- a/packages/shared/src/polyfills/index.ts
+++ b/packages/shared/src/polyfills/index.ts
@@ -2,20 +2,19 @@
 // import { clearIntervalAsync, setIntervalAsync } from 'set-interval-async';
 
 // walletconnect react-native-compat polyfill
-import './reactCreateElementShim';
 import './walletConnectCompact';
 import './polyfillsPlatform';
 
+import './reactCreateElementShim';
 import '../modules3rdParty/cross-crypto/verify';
-
 import '../request';
 
 // import { normalizeRequestLibs } from '../request/normalize';
 import timerUtils from '../utils/timerUtils';
 // @ts-ignore
-// globalThis.setInterval = setIntervalAsync;
+// global.setInterval = setIntervalAsync;
 // // @ts-ignore
-// globalThis.clearInterval = clearIntervalAsync;
+// global.clearInterval = clearIntervalAsync;
 // import { interceptConsoleErrorWithExtraInfo } from '../errors/utils/errorUtils';
 
 // normalizeRequestLibs();
diff --git a/packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts b/packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts
index 96d47b49f261..5d3af02023c2 100644
--- a/packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts
+++ b/packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts
@@ -1,45 +1,49 @@
+/* eslint-disable unicorn/prefer-global-this */
 import storageChecker from '../../storageChecker/storageChecker';
 
 // @ts-ignore
-globalThis.IDBDatabase.prototype.transactionOriginal_a7c9d6a9 =
-  // eslint-disable-next-line @typescript-eslint/unbound-method
-  globalThis.IDBDatabase.prototype.transaction;
-globalThis.IDBDatabase.prototype.transaction = function (
-  storeNames: string | string[],
-  mode?: IDBTransactionMode,
-  options?: IDBTransactionOptions,
-) {
-  // eslint-disable-next-line @typescript-eslint/no-this-alias
-  const self = this;
-  try {
-    const isWriteMode = mode !== 'readonly';
-    if (isWriteMode && globalThis.$onekeySystemDiskIsFull) {
-      console.error('IndexedDB==>checkDiskFull ', self, {
-        name: self.name,
-        storeNames,
-        mode,
-        options,
-      });
-    }
-    if (isWriteMode) {
-      storageChecker.checkIfDiskIsFullSync();
-      void storageChecker.checkIfDiskIsFullDebounced();
-    }
-    const tx =
-      // @ts-ignore
-      // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
-      globalThis.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
+if (!global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9) {
+  // @ts-ignore
+  global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9 =
+    // eslint-disable-next-line @typescript-eslint/unbound-method
+    global.IDBDatabase.prototype.transaction;
+  global.IDBDatabase.prototype.transaction = function (
+    storeNames: string | string[],
+    mode?: IDBTransactionMode,
+    options?: IDBTransactionOptions,
+  ) {
+    // eslint-disable-next-line @typescript-eslint/no-this-alias
+    const self = this;
+    try {
+      const isWriteMode = mode !== 'readonly';
+      if (isWriteMode && global.$onekeySystemDiskIsFull) {
+        console.error('IndexedDB==>checkDiskFull ', self, {
+          name: self.name,
+          storeNames,
+          mode,
+          options,
+        });
+      }
+      if (isWriteMode) {
+        storageChecker.checkIfDiskIsFullSync();
+        void storageChecker.checkIfDiskIsFullDebounced();
+      }
+      const tx =
         // @ts-ignore
-        self,
-        // @ts-ignore
-        // eslint-disable-next-line prefer-rest-params
-        arguments,
-      );
+        // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
+        global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
+          // @ts-ignore
+          self,
+          // @ts-ignore
+          // eslint-disable-next-line prefer-rest-params
+          arguments,
+        );
 
-    // eslint-disable-next-line @typescript-eslint/no-unsafe-return
-    return tx;
-  } catch (error) {
-    storageChecker.handleDiskFullError(error);
-    throw error;
-  }
-};
+      // eslint-disable-next-line @typescript-eslint/no-unsafe-return
+      return tx;
+    } catch (error) {
+      storageChecker.handleDiskFullError(error);
+      throw error;
+    }
+  };
+}
diff --git a/packages/shared/src/polyfills/polyfillsPlatform.ext.ts b/packages/shared/src/polyfills/polyfillsPlatform.ext.ts
index a3765f7e338b..789ad8481928 100644
--- a/packages/shared/src/polyfills/polyfillsPlatform.ext.ts
+++ b/packages/shared/src/polyfills/polyfillsPlatform.ext.ts
@@ -1,30 +1,9 @@
 /* eslint-disable import/order */
 import 'core-js/es7/global';
-import 'setimmediate';
 import 'globalthis';
-import browser from 'webextension-polyfill'; // or extensionizer
+import './setimmediateShim';
+import './extensionApiShim/extensionApiShim';
+import './indexedDBShim/indexedDBShim';
 import './xhrShim';
 
-import platformEnv from '@onekeyhq/shared/src/platformEnv';
-
-/*
-requestAnimationFrame is missing in mv3 background:
-  ReferenceError: requestAnimationFrame is not defined
- */
-if (typeof globalThis.requestAnimationFrame === 'undefined') {
-  globalThis.requestAnimationFrame = setImmediate;
-}
-
-// TODO move to polyfill file
-if (platformEnv.isRuntimeFirefox) {
-  // @ts-ignore
-  browser.$$isPolyfill = true;
-  // @ts-ignore
-  globalThis.chromeLegacy = globalThis.chrome;
-  // @ts-ignore
-  globalThis.chrome = browser;
-} else {
-  globalThis.browser = globalThis.browser || browser;
-}
-
 console.log('polyfillsPlatform.ext shim loaded');
diff --git a/packages/shared/src/polyfills/polyfillsPlatform.js b/packages/shared/src/polyfills/polyfillsPlatform.js
index c6f65d470a14..eaee835a837e 100644
--- a/packages/shared/src/polyfills/polyfillsPlatform.js
+++ b/packages/shared/src/polyfills/polyfillsPlatform.js
@@ -1,6 +1,6 @@
 /* eslint-disable unicorn/prefer-global-this */
 /* eslint-disable global-require, no-restricted-syntax, import/no-unresolved */
-require('setimmediate');
+require('./setimmediateShim');
 require('./intlShim');
 require('react-native-url-polyfill/auto');
 const platformEnv = require('@onekeyhq/shared/src/platformEnv');
diff --git a/packages/shared/src/polyfills/polyfillsPlatform.web.js b/packages/shared/src/polyfills/polyfillsPlatform.web.js
index 95284def85ed..f05d5ebe31be 100644
--- a/packages/shared/src/polyfills/polyfillsPlatform.web.js
+++ b/packages/shared/src/polyfills/polyfillsPlatform.web.js
@@ -1,3 +1,3 @@
 // check  polyfillsPlatform.ext.ts  or   polyfillsPlatform.native.js
-import 'setimmediate';
+import './setimmediateShim';
 import './indexedDBShim/indexedDBShim';
diff --git a/packages/shared/src/polyfills/setimmediateShim.ts b/packages/shared/src/polyfills/setimmediateShim.ts
new file mode 100644
index 000000000000..b641df376a2a
--- /dev/null
+++ b/packages/shared/src/polyfills/setimmediateShim.ts
@@ -0,0 +1,10 @@
+/* eslint-disable unicorn/prefer-global-this */
+import 'setimmediate';
+
+/*
+requestAnimationFrame is missing in mv3 background:
+  ReferenceError: requestAnimationFrame is not defined
+ */
+if (typeof global.requestAnimationFrame === 'undefined') {
+  global.requestAnimationFrame = setImmediate;
+}
diff --git a/packages/shared/src/polyfills/xhrShim/xhrShimV1.ts b/packages/shared/src/polyfills/xhrShim/xhrShimV1.ts
index 2157e93916a0..980053352267 100644
--- a/packages/shared/src/polyfills/xhrShim/xhrShimV1.ts
+++ b/packages/shared/src/polyfills/xhrShim/xhrShimV1.ts
@@ -1,3 +1,4 @@
+/* eslint-disable unicorn/prefer-global-this */
 /* eslint-disable spellcheck/spell-checker */
 // eslint-disable-next-line max-classes-per-file
 const sErrored = Symbol('errored');
@@ -254,5 +255,5 @@ const XMLHttpRequestShim = class XMLHttpRequest extends Dispatch {
   }
 };
 
-globalThis.XMLHttpRequest = globalThis.XMLHttpRequest || XMLHttpRequestShim;
-export default globalThis.XMLHttpRequest;
+global.XMLHttpRequest = global.XMLHttpRequest || XMLHttpRequestShim;
+export default global.XMLHttpRequest;
diff --git a/packages/shared/src/polyfills/xhrShim/xhrShimV2.ts b/packages/shared/src/polyfills/xhrShim/xhrShimV2.ts
index e1a641e55fa7..947972fcf85b 100644
--- a/packages/shared/src/polyfills/xhrShim/xhrShimV2.ts
+++ b/packages/shared/src/polyfills/xhrShim/xhrShimV2.ts
@@ -1,3 +1,4 @@
+/* eslint-disable unicorn/prefer-global-this */
 /* eslint-disable spellcheck/spell-checker */
 // @ts-nocheck
 // eslint-disable-next-line max-classes-per-file
@@ -553,7 +554,7 @@ export class XMLHttpRequest extends XMLHttpRequestEventTarget {
     try {
       let base: string | undefined;
       try {
-        base = globalThis.location.toString();
+        base = global.location.toString();
       } catch {
         // we just want to avoid the error about location in Deno
       }
@@ -777,7 +778,7 @@ function maybeDefine(value: any, name: string, scope: object) {
     enumerable: false,
     configurable: true,
   });
-  if (!(name in globalThis)) {
+  if (!(name in global)) {
     Object.defineProperty(scope, name, {
       value,
       writable: true,
@@ -787,6 +788,6 @@ function maybeDefine(value: any, name: string, scope: object) {
   }
 }
 
-maybeDefine(XMLHttpRequest, 'XMLHttpRequest', globalThis);
-maybeDefine(XMLHttpRequestEventTarget, 'XMLHttpRequestEventTarget', globalThis);
-maybeDefine(XMLHttpRequestUpload, 'XMLHttpRequestUpload', globalThis);
+maybeDefine(XMLHttpRequest, 'XMLHttpRequest', global);
+maybeDefine(XMLHttpRequestEventTarget, 'XMLHttpRequestEventTarget', global);
+maybeDefine(XMLHttpRequestUpload, 'XMLHttpRequestUpload', global);
diff --git a/packages/shared/src/storageChecker/storageChecker.ts b/packages/shared/src/storageChecker/storageChecker.ts
index 51e82e36dffd..91f4cd56990f 100644
--- a/packages/shared/src/storageChecker/storageChecker.ts
+++ b/packages/shared/src/storageChecker/storageChecker.ts
@@ -14,6 +14,9 @@ import platformEnv from '../platformEnv';
 
 const diskFullErrorMessage = `Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing`;
 
+const warningAtGB = 0.936;
+// const warningAtGB = 1110.936;
+
 function handleDiskFullError(error: unknown) {
   const err = error as Error | undefined;
   if (err && err?.message && err?.message.includes(diskFullErrorMessage)) {
@@ -50,7 +53,7 @@ async function checkIfDiskIsFull() {
             usageInGB,
             availableInGB,
           });
-          if (availableInGB < 0.936) {
+          if (availableInGB < warningAtGB) {
             globalThis.$onekeySystemDiskIsFull = true;
           }
         }


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: ASSERTIVE**
**Plan: Pro**
**Cache: Disabled due to data retention organization setting**
**Knowledge Base: Disabled due to data retention organization setting**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 8b71f01ee9f42430d21b284032aa5d4b50fe0999 and 332b77ad096ade8360afbe3bc7058bb70b33b7cd.

</details>

<details>
<summary>📒 Files selected for processing (10)</summary>

* `packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts` (1 hunks)
* `packages/shared/src/polyfills/index.ts` (1 hunks)
* `packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts` (1 hunks)
* `packages/shared/src/polyfills/polyfillsPlatform.ext.ts` (1 hunks)
* `packages/shared/src/polyfills/polyfillsPlatform.js` (1 hunks)
* `packages/shared/src/polyfills/polyfillsPlatform.web.js` (1 hunks)
* `packages/shared/src/polyfills/setimmediateShim.ts` (1 hunks)
* `packages/shared/src/polyfills/xhrShim/xhrShimV1.ts` (2 hunks)
* `packages/shared/src/polyfills/xhrShim/xhrShimV2.ts` (4 hunks)
* `packages/shared/src/storageChecker/storageChecker.ts` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts (1)</summary><blockquote>

<details>
<summary>packages/shared/src/polyfills/polyfillsPlatform.js (1)</summary>

* `platformEnv` (6-6)

</details>

</blockquote></details>

</details><details>
<summary>🪛 Biome (1.9.4)</summary>

<details>
<summary>packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts</summary>

[error] 16-16: This aliasing of this is unnecessary.

Arrow functions inherits `this` from their enclosing scope.
Safe fix: Use this instead of an alias.


(lint/complexity/noUselessThisAlias)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (15)</summary><blockquote>

<details>
<summary>packages/shared/src/polyfills/setimmediateShim.ts (1)</summary>

`1-10`: **Clean implementation of requestAnimationFrame polyfill.**

The code properly provides requestAnimationFrame for MV3 background contexts using setImmediate. This approach ensures animation-related code works consistently across environments.

</details>
<details>
<summary>packages/shared/src/polyfills/polyfillsPlatform.web.js (1)</summary>

`2-2`: **Good refactoring of setImmediate import.**

Changed to use the local shim instead of importing the package directly. This centralizes polyfill logic and improves maintainability.

</details>
<details>
<summary>packages/shared/src/polyfills/polyfillsPlatform.js (1)</summary>

`3-3`: **Consistent setImmediate import refactoring.**

Updated to use the local shim module instead of direct package import, matching the pattern used in other platform files.

</details>
<details>
<summary>packages/shared/src/polyfills/index.ts (2)</summary>

`8-8`: **Correct import ordering.**

Moved reactCreateElementShim import after polyfillsPlatform to ensure proper dependency resolution.

---

`15-17`: **Standardized global object references.**

Updated commented code to use 'global' instead of 'globalThis', maintaining consistency with project standards.

</details>
<details>
<summary>packages/shared/src/storageChecker/storageChecker.ts (2)</summary>

`17-18`: **Good extraction of magic number to named constant.**

Extracting the hardcoded value 0.936 to a named constant `warningAtGB` improves code readability and maintainability.

---

`56-56`: **LGTM - Proper use of the new constant.**

Using the constant instead of the magic number makes the code more maintainable.

</details>
<details>
<summary>packages/shared/src/polyfills/xhrShim/xhrShimV1.ts (2)</summary>

`1-1`: **Appropriate ESLint directive added.**

The eslint directive properly disables the rule that would otherwise flag the intentional use of `global` instead of `globalThis`.

---

`258-259`: **Consistent use of global object references.**

Changing from `globalThis` to `global` aligns with the broader standardization pattern across polyfill modules.

</details>
<details>
<summary>packages/shared/src/polyfills/xhrShim/xhrShimV2.ts (4)</summary>

`1-1`: **Appropriate ESLint directive added.**

The eslint directive properly disables the rule that would otherwise flag the intentional use of `global` instead of `globalThis`.

---

`557-557`: **Consistent use of global object references in open method.**

Changing from `globalThis` to `global` maintains consistency with other polyfill modules.

---

`781-781`: **Consistent use of global object reference in maybeDefine function.**

Using `global` instead of `globalThis` aligns with the standardization across the codebase.

---

`791-793`: **Consistent use of global object in maybeDefine calls.**

All references properly updated to use `global` instead of `globalThis` for consistency.

</details>
<details>
<summary>packages/shared/src/polyfills/polyfillsPlatform.ext.ts (1)</summary>

`4-6`: **Good refactoring of imports to use local shim modules.**

Replacing external dependencies with local shim modules provides better control over polyfill implementation. This improves maintainability and reduces external dependencies.

</details>
<details>
<summary>packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts (1)</summary>

`5-9`: **Good addition of the guard clause**

Adding this guard prevents multiple overrides of the transaction method. The unique suffix on the original method name helps avoid collisions.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-23T08:30:58Z
user: login: limichange
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-23T10:19:17Z
user: login: huhuanming
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-23T10:46:14Z

Review comments:
diff_hunk: @@ -0,0 +1,16 @@
+/* eslint-disable unicorn/prefer-global-this */
+import browser from 'webextension-polyfill'; // or extensionizer
+
+import platformEnv from '../../platformEnv';
+
+// TODO move to polyfill file
+if (platformEnv.isRuntimeFirefox) {
+  // @ts-ignore
+  browser.$$isPolyfill = true;
+  // @ts-ignore
+  global.chromeLegacy = global.chrome;
+  // @ts-ignore
+  global.chrome = browser;
+} else {
+  global.browser = global.browser || browser;
+}
path: packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts
user: login: coderabbitai[bot]
body: _🧹 Nitpick (assertive)_

**Nice job adding the extension API shim**

This new file successfully unifies browser extension API usage across different environments. The approach handles Firefox's differences cleanly by preserving the legacy API while standardizing on the polyfill.

A few suggestions:

1. Add a brief comment explaining the purpose of `$$isPolyfill` flag
2. Consider handling Chrome Manifest V3 differences explicitly  
3. Document why multiple `@ts-ignore` comments are needed



```diff
 /* eslint-disable unicorn/prefer-global-this */
 import browser from 'webextension-polyfill'; // or extensionizer

 import platformEnv from '../../platformEnv';

-// TODO move to polyfill file
+// Unify browser extension APIs across different browsers
+// Firefox uses browser.* while Chrome uses chrome.*
 if (platformEnv.isRuntimeFirefox) {
   // @ts-ignore
+  // Mark the polyfill to distinguish from native browser APIs
   browser.$$isPolyfill = true;
   // @ts-ignore
+  // Preserve native chrome API for legacy access
   global.chromeLegacy = global.chrome;
   // @ts-ignore
+  // Replace chrome with the browser polyfill in Firefox
   global.chrome = browser;
 } else {
+  // Ensure browser API exists in Chrome and other browsers
   global.browser = global.browser || browser;
 }
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
/* eslint-disable unicorn/prefer-global-this */
import browser from 'webextension-polyfill'; // or extensionizer

import platformEnv from '../../platformEnv';

// Unify browser extension APIs across different browsers
// Firefox uses browser.* while Chrome uses chrome.*
if (platformEnv.isRuntimeFirefox) {
  // @ts-ignore
  // Mark the polyfill to distinguish from native browser APIs
  browser.$$isPolyfill = true;
  // @ts-ignore
  // Preserve native chrome API for legacy access
  global.chromeLegacy = global.chrome;
  // @ts-ignore
  // Replace chrome with the browser polyfill in Firefox
  global.chrome = browser;
} else {
  // Ensure browser API exists in Chrome and other browsers
  global.browser = global.browser || browser;
}
```

</details>

<!-- suggestion_end -->

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In packages/shared/src/polyfills/extensionApiShim/extensionApiShim.ts lines 1 to
16, add a brief comment above the $$isPolyfill flag explaining its purpose as an
indicator that the browser object is a polyfill. Add handling for Chrome
Manifest V3 differences explicitly, such as checking for the manifest version
and adjusting the API shim accordingly. Also, add comments explaining why the
multiple @ts-ignore directives are necessary, clarifying that they suppress
TypeScript errors due to modifying global objects or properties not declared in
typings.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-23T08:30:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,45 +1,49 @@
+/* eslint-disable unicorn/prefer-global-this */
 import storageChecker from '../../storageChecker/storageChecker';
 
 // @ts-ignore
-globalThis.IDBDatabase.prototype.transactionOriginal_a7c9d6a9 =
-  // eslint-disable-next-line @typescript-eslint/unbound-method
-  globalThis.IDBDatabase.prototype.transaction;
-globalThis.IDBDatabase.prototype.transaction = function (
-  storeNames: string | string[],
-  mode?: IDBTransactionMode,
-  options?: IDBTransactionOptions,
-) {
-  // eslint-disable-next-line @typescript-eslint/no-this-alias
-  const self = this;
-  try {
-    const isWriteMode = mode !== 'readonly';
-    if (isWriteMode && globalThis.$onekeySystemDiskIsFull) {
-      console.error('IndexedDB==>checkDiskFull ', self, {
-        name: self.name,
-        storeNames,
-        mode,
-        options,
-      });
-    }
-    if (isWriteMode) {
-      storageChecker.checkIfDiskIsFullSync();
-      void storageChecker.checkIfDiskIsFullDebounced();
-    }
-    const tx =
-      // @ts-ignore
-      // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
-      globalThis.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
+if (!global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9) {
+  // @ts-ignore
+  global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9 =
+    // eslint-disable-next-line @typescript-eslint/unbound-method
+    global.IDBDatabase.prototype.transaction;
+  global.IDBDatabase.prototype.transaction = function (
+    storeNames: string | string[],
+    mode?: IDBTransactionMode,
+    options?: IDBTransactionOptions,
+  ) {
+    // eslint-disable-next-line @typescript-eslint/no-this-alias
+    const self = this;
+    try {
+      const isWriteMode = mode !== 'readonly';
+      if (isWriteMode && global.$onekeySystemDiskIsFull) {
+        console.error('IndexedDB==>checkDiskFull ', self, {
+          name: self.name,
+          storeNames,
+          mode,
+          options,
+        });
+      }
+      if (isWriteMode) {
+        storageChecker.checkIfDiskIsFullSync();
+        void storageChecker.checkIfDiskIsFullDebounced();
+      }
+      const tx =
         // @ts-ignore
-        self,
-        // @ts-ignore
-        // eslint-disable-next-line prefer-rest-params
-        arguments,
-      );
+        // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
+        global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
+          // @ts-ignore
+          self,
+          // @ts-ignore
+          // eslint-disable-next-line prefer-rest-params
+          arguments,
+        );
 
-    // eslint-disable-next-line @typescript-eslint/no-unsafe-return
-    return tx;
-  } catch (error) {
-    storageChecker.handleDiskFullError(error);
-    throw error;
-  }
-};
+      // eslint-disable-next-line @typescript-eslint/no-unsafe-return
+      return tx;
+    } catch (error) {
+      storageChecker.handleDiskFullError(error);
+      throw error;
+    }
+  };
path: packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts
user: login: coderabbitai[bot]
body: _🧹 Nitpick (assertive)_

**Refactor to use arrow function instead of this alias**

The function uses a this alias unnecessarily. Arrow functions automatically inherit the parent's this context.


```diff
-  global.IDBDatabase.prototype.transaction = function (
+  global.IDBDatabase.prototype.transaction = function (
     storeNames: string | string[],
     mode?: IDBTransactionMode,
     options?: IDBTransactionOptions,
   ) {
-    // eslint-disable-next-line @typescript-eslint/no-this-alias
-    const self = this;
+    // No need for self = this when using references directly
     try {
       const isWriteMode = mode !== 'readonly';
       if (isWriteMode && global.$onekeySystemDiskIsFull) {
         console.error('IndexedDB==>checkDiskFull ', self, {
-          name: self.name,
+          name: this.name,
           storeNames,
           mode,
           options,
         });
       }
       if (isWriteMode) {
         storageChecker.checkIfDiskIsFullSync();
         void storageChecker.checkIfDiskIsFullDebounced();
       }
       const tx =
         // @ts-ignore
         // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
         global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
           // @ts-ignore
-          self,
+          this,
           // @ts-ignore
           // eslint-disable-next-line prefer-rest-params
           arguments,
         );

       // eslint-disable-next-line @typescript-eslint/no-unsafe-return
       return tx;
     } catch (error) {
       storageChecker.handleDiskFullError(error);
       throw error;
     }
   };
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
  global.IDBDatabase.prototype.transaction = function (
    storeNames: string | string[],
    mode?: IDBTransactionMode,
    options?: IDBTransactionOptions,
  ) {
    // No need for self = this when using references directly
    try {
      const isWriteMode = mode !== 'readonly';
      if (isWriteMode && global.$onekeySystemDiskIsFull) {
        console.error('IndexedDB==>checkDiskFull ', this, {
          name: this.name,
          storeNames,
          mode,
          options,
        });
      }
      if (isWriteMode) {
        storageChecker.checkIfDiskIsFullSync();
        void storageChecker.checkIfDiskIsFullDebounced();
      }
      const tx =
        // @ts-ignore
        // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
        global.IDBDatabase.prototype.transactionOriginal_a7c9d6a9.apply(
          // @ts-ignore
          this,
          // @ts-ignore
          // eslint-disable-next-line prefer-rest-params
          arguments,
        );

      // eslint-disable-next-line @typescript-eslint/no-unsafe-return
      return tx;
    } catch (error) {
      storageChecker.handleDiskFullError(error);
      throw error;
    }
  };
```

</details>

<!-- suggestion_end -->

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Biome (1.9.4)</summary>

[error] 16-16: This aliasing of this is unnecessary.

Arrow functions inherits `this` from their enclosing scope.
Safe fix: Use this instead of an alias.


(lint/complexity/noUselessThisAlias)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In packages/shared/src/polyfills/indexedDBShim/indexedDBShim.ts between lines 10
and 48, the transaction function uses a this alias (const self = this) which is
unnecessary. Refactor the function to be an arrow function so it inherits the
parent's this context automatically, and remove the this alias usage inside the
function accordingly.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-23T08:30:57Z
author_association: CONTRIBUTOR

PR comments:
user: login: codesandbox[bot]
created_at: 2025-05-23T07:49:24Z
body: #### Review or Edit in CodeSandbox

Open the branch in <a href="https://codesandbox.io/p/github/OneKeyHQ/app-monorepo/fix/ext-storage-check?mode=review&utm_source=gh_app">Web Editor</a> &bull; <a href="https://codesandbox.io/p/vscode?owner=OneKeyHQ&repo=app-monorepo&branch=fix/ext-storage-check&utm_source=gh_app">VS Code</a> &bull; <a href="https://codesandbox.io/p/vscode?owner=OneKeyHQ&repo=app-monorepo&branch=fix/ext-storage-check&insiders=true&utm_source=gh_app">Insiders</a><br>
Open <a href="https://codesandbox.io/p/devtool/preview/OneKeyHQ/app-monorepo/fix/ext-storage-check?task=preview&port=51423&redirect=true&utm_source=gh_app">Preview</a>

<!-- open-in-codesandbox:complete -->

author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-05-23T07:49:28Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

The updates introduce new polyfill shims for extension APIs and setImmediate, refactor polyfill imports, and standardize global object references. They also add a guard to prevent multiple overrides of the IndexedDB transaction method, and replace hardcoded disk space thresholds with a named constant. No exported APIs are changed.

## Changes

| File(s)                                                                                 | Change Summary                                                                                                      |
|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| .../polyfills/extensionApiShim/extensionApiShim.ts                                      | New polyfill shim for browser extension APIs, unifying `chrome` and `browser` objects across environments.          |
| .../polyfills/setimmediateShim.ts                                                       | New polyfill module for `setImmediate`. Polyfills `requestAnimationFrame` with `setImmediate` if missing.           |
| .../polyfills/indexedDBShim/indexedDBShim.ts                                            | Adds a guard to prevent multiple overrides of `IDBDatabase.prototype.transaction`. Uses `global` instead of `globalThis`. |
| .../polyfills/xhrShim/xhrShimV1.ts<br>.../polyfills/xhrShim/xhrShimV2.ts                | Changes all references from `globalThis` to `global` for global object access and property assignment.              |
| .../polyfills/polyfillsPlatform.ext.ts                                                  | Replaces direct imports of polyfills with local shims. Removes manual global object manipulations and requestAnimationFrame polyfill logic. |
| .../polyfills/polyfillsPlatform.js<br>.../polyfills/polyfillsPlatform.web.js            | Switches `setimmediate` import from external package to local shim implementation.                                  |
| .../polyfills/index.ts                                                                  | Adjusts import order. Updates comments to use `global` instead of `globalThis`. No functional changes.              |
| .../storageChecker/storageChecker.ts                                                    | Replaces a hardcoded disk space threshold with a named constant `warningAtGB`.                                      |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant App
    participant extensionApiShim
    participant webextension-polyfill

    App->>extensionApiShim: Import/Require
    extensionApiShim->>webextension-polyfill: Import polyfill
    extensionApiShim->>extensionApiShim: Detect runtime (e.g., Firefox)
    alt Firefox
        extensionApiShim->>extensionApiShim: Mark browser as polyfill
        extensionApiShim->>extensionApiShim: Save chrome as chromeLegacy
        extensionApiShim->>extensionApiShim: Replace chrome with browser polyfill
    else Other browsers
        extensionApiShim->>extensionApiShim: Ensure global browser exists
    end
    App-->>extensionApiShim: Use unified extension API
```

```mermaid
sequenceDiagram
    participant App
    participant setimmediateShim
    participant setimmediate

    App->>setimmediateShim: Import/Require
    setimmediateShim->>setimmediate: Import setImmediate
    setimmediateShim->>setimmediateShim: Check if requestAnimationFrame exists
    alt Not defined
        setimmediateShim->>setimmediateShim: Polyfill requestAnimationFrame with setImmediate
    end
    App-->>setimmediateShim: Use setImmediate/requestAnimationFrame as needed
```

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!NOTE]
> <details>
> <summary>⚡️ AI Code Reviews for VS Code, Cursor, Windsurf</summary>
> 
> CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
> Learn more [here](http://coderabbit.ai/ide).
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4AxeAA8A9CXu5IiAlVKNYogNYGAHLYzAKUXADsAMwAnAAMBgCqiOHu8LTM+BTwAF74GEb6xuBQZPT4AGY4BMRkyjT0TKzsXLz8wqLiUjLyTEpUqupaOkUmUHCoqJjVhKTkVA0KzRickFQA7u4hzGgU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EPjcPIBJm8UtH2KpWG2DmBW5CcOBLkgHney8PG0PE6DLLpLIlDPWQYqYpYroUCxHDKB1NVNGNn0Wl51Cywgm2PFAunBtTdInzFG2LyxWHlxoCZXNkoT6TKXl2yUUQ/3I371nSLAgRDjC2dVqNdXbKYl8D4D8yaP5T4G1VoBzDyNG2rnVGwlhV3HoQrEKjoFd0jXHJjQeKnJ9xqlnPwP3P20PJD1zRXJ+i91jwys2z4HXOoE3KyuLXTVype3rCHKjzIPhN3SRIPRoMvNBw8CyDtExmG0oBeE8F6v6ooDfI4JJMfTJJ4Ob0xyKs5CZM2HdRcouTBll01mhFwAAHFj5oK2UzxbYLB1MUY4gNAYgohzF6EFl1QRUnFYFALUoRwTpaAU56A5M2Bsh2ocwo1sITqzqLrDLJKyokA/B3AUpWkLjKo1AvrehhtysbxBEsUYNJsmhbhsgassAYwVFtBIarBdZtrIBgBIBfrzrpDdRuBIoQtXSUhVpPJ+5lrPSaBzIuINAtoFxMaIari8bj4CbXFdgVIiANrtqRjxYg0lEPMADK49ZaBFZOslsTjJB7QDqjqlM4w+b1qtqdrIBHl8SdbibzEPk4qM4YZlYgTDKfLOy/MIr8hZDorgJFraTJomqkqxycDJztzfdqqA9oS8rPjZ4fsigDAxgvRygqhmyahJrFhJbVgNhpqCwDgU4BgThhhzhDAg65Z1ADF0hEADEpNmS6ADEu9S4A6g6ogohnyBAIgIhzI4gYhLElAAAOc6uIDmMIKIAQBgCIOIAAVnrtUE7oEFLoroYHoGLpKCWGYAzqzpzpIB9DztoAMWUv0CAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=OneKeyHQ/app-monorepo&utm_content=7390):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` or `Summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR