Skip to content

[framework-context] Preserve the primary request failure when onRequestError throws #2007

Closed

Description

@kang-heewon

Priority

P1

Problem

The request catch path awaits onRequestError before rethrowing the captured application failure. If the hook rejects, its error replaces the primary request error.

Evidence

Source of truth: origin/trunk@678073d994294db7e21b5a4d0a004a087ea498e0.

  • packages/framework-context/src/libs/Context.ts:103-120 invokes and awaits onRequestError inside the catch block before rethrowing the captured value.

Desired outcome

Request callers, filters, and telemetry always receive the original failure while hook failures remain observable.

Proposed implementation

  1. Contain onRequestError failure separately from the primary request error.
  2. Report or attach hook-failure diagnostics without changing the primary rejection.
  3. Cover Error and non-Error primary failures.

Acceptance criteria

  • The original failure identity is preserved when onRequestError succeeds or fails.
  • Non-Error thrown values retain existing semantics.
  • Hook failures remain available as explicit diagnostic evidence.
  • Request start/end success behavior does not change.

Validation

  • pnpm --dir packages/framework-context vitest run src/tests/FrameworkContext.spec.ts
  • pnpm --filter @croco/framework-context typecheck

Scope boundaries

Do not change onRequestStart or onRequestEnd success semantics.

Activity

  1. added
    bugSomething isn't working
    error-handlingError handling and failure semantics
    P1Priority 1 issue
    runtimeRuntime behavior, lifecycle, and environment capability work
    on Aug 23, 2026
  2. self-assigned this
    on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1Priority 1 issuebugSomething isn't workingerror-handlingError handling and failure semanticsframework-contextruntimeRuntime behavior, lifecycle, and environment capability work

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions