Skip to content

[Feature] Promise executors to ensure reliable error propagation #2873

Description

@EmmaYuan1015

Description

Several asynchronous code paths use an async function directly as the
executor passed to the Promise constructor:

  • src/common/packageLoader.ts
  • src/debugger/rnDebugSession.ts
  • src/extension/networkInspector/networkInspectorServer.ts

The Promise constructor does not observe the promise returned by an async
executor. An exception thrown after an await can therefore become an
unhandled rejection instead of rejecting the outer promise.

This can result in incomplete initialization, hanging operations, or errors
that bypass the expected error-handling flow.

Expected behavior

All asynchronous failures should reliably reject the promise returned by the
owning operation and reach its existing error handler.

Event-driven operations should retain their current completion semantics while
using a synchronous Promise executor.

Proposed solution

  • Keep the Promise executor synchronous in the package loader and debugger
    attach flow.
  • Explicitly connect asynchronous work to the outer promise with
    .catch(reject).
  • Replace the unnecessary Promise constructor in the Network Inspector server
    with a regular async initialization method.
  • Preserve the existing package installation, debugger connection, and
    concurrent stop behavior.

Validation

  • The project builds with zero errors.
  • The modified files have no TypeScript or editor diagnostics.
  • Network Inspector tests pass.
  • None of the affected code paths use new Promise(async ...) after the
    change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions