Skip to content

Enforce explicit async error boundaries - #75

Merged
rdlabo merged 1 commit into
mainfrom
agent/enable-restrict-try-block
Aug 14, 2026
Merged

Enforce explicit async error boundaries#75
rdlabo merged 1 commit into
mainfrom
agent/enable-restrict-try-block

Conversation

@rdlabo

@rdlabo rdlabo commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add @rdlabo/eslint-plugin-rules v21.2.6 and enable typed @rdlabo/rules/restrict-try-block linting
  • replace broad try/catch blocks and Promise.resolve() scheduling with explicit synchronous boundaries, Promise rejection paths, and deterministic cleanup
  • preserve PDF output cleanup, offline transaction rollback, auth recovery, overlay, realtime, and HTTP error semantics with regression coverage

Why

Broad try/catch blocks can accidentally hide rejected Promises or classify cleanup failures as primary operation failures. The shared kit now enforces small, responsible synchronous error boundaries and explicit asynchronous handling at lint time.

Review fixes

  • preserve the OfflineSync ErrorHandler microtask boundary and absorb reporter failures
  • normalize synchronous phased-resume and repository-initialization throws through their existing unavailable-error paths
  • preserve original SQLite write failures when rollback also fails

Validation

  • npm run lint
  • npx ng test kit --watch=false (45 files, 841 tests)
  • npx ng build kit --configuration=production
  • git diff --check
  • senior review: APPROVE
  • independent review: APPROVE

@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for rdlabo-ionic-angular-library ready!

Name Link
🔨 Latest commit 1a85b1b
🔍 Latest deploy log https://app.netlify.com/projects/rdlabo-ionic-angular-library/deploys/6a7eb00a831c1e0008498ecd
😎 Deploy Preview https://deploy-preview-75--rdlabo-ionic-angular-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@rdlabo
rdlabo marked this pull request as ready for review August 14, 2026 06:05

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +1493 to +1501
let result: unknown;
try {
result = (this.#errorHandler.handleError as (reportedError: unknown) => unknown)(error);
} catch {
return;
}
if (result instanceof Promise) {
void result.catch(() => undefined);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 オフライン同期のバックグラウンド失敗がアプリのエラー報告先に届かなくなる

エラー報告の呼び出し(offline-sync.service.ts:1495handleError 呼び出し)がメソッドを持ち主から切り離して実行するため、報告処理自体が失敗し、その失敗も握りつぶされるので、バックグラウンドの同期エラーが誰にも通知されなくなります。

Impact: 同期・プル・フック失敗の通知がアプリのエラー報告(ログ/監視)に一切届かず、障害が無言で消えます。

レシーバを失った `handleError` 呼び出しの仕組み

#dispatchErrorthis.#errorHandler.handleError を関数値として取り出し、レシーバ無しで呼び出しています(projects/kit/offline/src/lib/offline-sync.service.ts:1495)。この形では呼び出し時の thisundefined になるため、this を参照する ErrorHandler 実装(Angular 既定実装の this._findOriginalError(...) や、DI したロガー等を this 経由で使うアプリ独自ハンドラ)は TypeError を投げます。その例外は直後の catch { return; }projects/kit/offline/src/lib/offline-sync.service.ts:1496-1498)で無言に破棄されるため、エラーは記録されません。

#reportError#flushInBackgroundprojects/kit/offline/src/lib/offline-sync.service.ts:868)や discardAllPendingonCommandRemoved 失敗経路(projects/kit/offline/src/lib/offline-sync.service.ts:855)から使われる唯一の報告経路です。変更前は this.#errorHandler.handleError(error) とメソッド呼び出しだったため this は保持されていました。

テストでは ErrorHandler{ handleError }(プレーンな vi.fn)で差し替えているため this を使わず、この退行は検出されません。

Suggested change
let result: unknown;
try {
result = (this.#errorHandler.handleError as (reportedError: unknown) => unknown)(error);
} catch {
return;
}
if (result instanceof Promise) {
void result.catch(() => undefined);
}
let result: unknown;
try {
result = this.#errorHandler.handleError(error) as unknown;
} catch {
return;
}
if (result instanceof Promise) {
void result.catch(() => undefined);
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@rdlabo
rdlabo merged commit 61630ad into main Aug 14, 2026
12 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