Skip to content

[Feature][High] Critical bug: lodash reject() shadows Promise.reject, plus deprecated RxJS ops, missing OnPush, and DRY violations #3401

@numbers-official

Description

@numbers-official

Summary

Five high-priority improvement findings discovered during automated deep check on 2026-04-10. Finding 1 is an active bug causing hanging promises. These are new findings not covered by existing issues.


1. CRITICAL BUG: lodash.reject() Shadows Promise.reject in getToken()

File: src/app/shared/dia-backend/auth/dia-backend-auth.service.ts lines 5, 434-444

import { isEqual, reject } from 'lodash-es';  // lodash's array-filter reject()

private async getToken() {
    return new Promise<string>(resolve => {  // Missing reject parameter!
      this.preferences.getString(PrefKeys.TOKEN).then(token => {
        if (token.length !== 0) {
          resolve(token);
        } else {
          reject(new Error('Cannot get DIA backend token which is empty.'));
          // ^ This calls lodash.reject(), NOT Promise.reject()
          // Returns an empty array and does nothing. Promise hangs forever.
        }
      });
    });
}

Impact: When the token is empty/missing, getToken() returns a permanently hanging promise. All authenticated API calls that depend on getToken() will deadlock. Users see infinite spinners with no error message.

Fix: Add reject to the Promise constructor: new Promise<string>((resolve, reject) => {...}). Remove the lodash reject import if unused elsewhere.


2. Deprecated RxJS Operators: repeatWhen, retryWhen, pluck

Files:

  • src/app/shared/dia-backend/asset/dia-backend-asset-repository.service.ts (repeatWhen, pluck)
  • src/app/shared/dia-backend/transaction/dia-backend-transaction-repository.service.ts (repeatWhen, pluck)
  • src/app/shared/dia-backend/contact/dia-backend-contact-repository.service.ts (repeatWhen)
  • src/app/shared/dia-backend/asset/uploading/dia-backend-asset-uploading.service.ts (retryWhen)

All three operators are deprecated in RxJS 7 and will be removed in RxJS 8. Replace:

  • repeatWhen(() => notifier$)repeat({ delay: () => notifier$ })
  • retryWhen(err$ => ...)retry({ delay: (err, attempt) => ... })
  • pluck('count')map(x => x.count)

3. Full lodash Bundle Import in proof.ts

File: src/app/shared/repositories/proof/proof.ts line 2

import { snakeCase } from 'lodash';  // Full CommonJS bundle (~530KB)

All other 8 files use 'lodash-es' (tree-shakable). This single import pulls the entire lodash bundle.

Fix: Change to import { snakeCase } from 'lodash-es';


4. No ChangeDetectionStrategy.OnPush on Any Component

Files: All 50+ components use the default ChangeDetectionStrategy.Default.

Zero components use OnPush. Every browser event, timer, or HTTP response triggers change detection across the entire component tree. The codebase already has workaround detectChanges() calls (found in home.page.ts, capture-tab.component.ts, details.page.ts, buy-num.page.ts).

Impact: Substantial performance degradation on mobile, especially during scroll interactions.

Fix: Progressively adopt OnPush starting with CaptureTabComponent, HomePage, DetailsPage. Existing ngrxPush/ngrxLet pipes already support OnPush.


5. Triplicated Logout/Account-Wipe Logic

Files:

  • src/app/features/home/home.page.ts lines 479-496
  • src/app/features/home/capture-tab/capture-tab.component.ts lines 246-263
  • src/app/features/settings/settings.page.ts lines 183-197

The logout sequence (mediaStore.clear()database.clear()preferenceManager.clear()reloadApp) is copy-pasted in 3 places.

Fix: Extract a shared LogoutService with the complete logout pipeline.

Generated by Heart Beat with Omni

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions