Skip to content

Add error boundary to the local API server #1318

Description

@l2ysho

src/lib/local-api-server.ts:86-103 reads the request body and awaits the route handler with no try/catch. A client aborting mid-body, or a handler that throws, becomes an unhandled rejection and can kill the CLI process during apify login or apify actor edit-input-schema.

Also, JSON.parse accepts null and arrays, so handlers reading properties off body get a non-object.

  • Wrap body read + dispatch in try/catch → 500 on handler throw
  • Reject non-object JSON with 400
  • Skip writing if res.destroyed || res.writableEnded

From the review of #1304. Part of #1305.


Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request.t-buildersIssues owned by the Builders team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions