Skip to content

fix: lodash.reject shadows Promise.reject, deprecated RxJS ops, lodash bundle, triplicated logout logic - #3405

Closed
numbers-official with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-lodash-reject-promise
Closed

fix: lodash.reject shadows Promise.reject, deprecated RxJS ops, lodash bundle, triplicated logout logic#3405
numbers-official with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-lodash-reject-promise

Conversation

Copilot AI commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Five code quality and correctness findings: one active bug causing permanently hanging promises, three deprecated RxJS operator usages, a full-bundle lodash import, and triplicated logout logic.

Critical Bug Fix: getToken() Promise Never Rejects

Promise constructor was missing the reject parameter, so the lodash array-filter reject() was called instead — silently returning [] and leaving the promise hanging forever when the token is empty.

// Before — calls lodash.reject(), promise hangs
import { isEqual, reject } from 'lodash-es';
return new Promise<string>(resolve => {
  ...
  reject(new Error('Cannot get DIA backend token which is empty.')); // lodash!
});

// After — correct Promise rejection
import { isEqual } from 'lodash-es';
return new Promise<string>((resolve, reject) => {
  ...
  reject(new Error('Cannot get DIA backend token which is empty.')); // Promise.reject
});

Deprecated RxJS Operators Replaced

Deprecated Replacement Files
repeatWhen(() => n$) repeat({ delay: () => n$ }) dia-backend-asset-repository, dia-backend-transaction-repository, dia-backend-contact-repository
retryWhen(err$ => err$.pipe(mergeMap((_, i) => timer(...)))) retry({ delay: (_, i) => timer(...) }) dia-backend-asset-uploading
pluck('count') map(x => x.count) same repos as repeatWhen

Lodash Full-Bundle Import in proof.ts

// Before — pulls entire ~530KB CJS bundle
import { snakeCase } from 'lodash';
// After — tree-shakable
import { snakeCase } from 'lodash-es';

Extracted LogoutService (DRY)

The wipe-and-reload pipeline (mediaStore.clear()database.clear()preferenceManager.clear()reloadApp) was copy-pasted across home.page.ts, capture-tab.component.ts, and settings.page.ts. Extracted into shared/logout/logout.service.ts with:

  • wipeAndReload$() — the shared clearing pipeline
  • logout$() — confirmation dialog + blocking action wrapper (used by home and capture-tab)
  • settings.page.ts deleteAccount() now chains diaBackendAuthService.deleteAccount$() into logoutService.wipeAndReload$()

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node index.js --exec install conf�� ut-json dist/docs.json --global iptables core.hooksPath (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits April 10, 2026 10:32
…d RxJS ops, lodash bundle, LogoutService extraction

Agent-Logs-Url: https://github.com/numbersprotocol/capture-cam/sessions/d549054c-bea6-4b57-b035-84119e871612

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
…home and capture-tab

Agent-Logs-Url: https://github.com/numbersprotocol/capture-cam/sessions/d549054c-bea6-4b57-b035-84119e871612

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix critical bug with lodash reject shadowing Promise.reject fix: lodash.reject shadows Promise.reject, deprecated RxJS ops, lodash bundle, triplicated logout logic Apr 10, 2026
Copilot AI requested a review from numbers-official April 10, 2026 10:36
@numbers-official

Copy link
Copy Markdown
Collaborator

Closing this stale Copilot draft PR. It is outdated against main, not merge-ready, and bundles broad automated changes without current full CI coverage. We should re-open focused PRs only for findings that are still valid after current main/Angular 21.

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.

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

2 participants