Skip to content

Handling uncaught HTTP exceptions #2

@nounder

Description

@nounder

With Server-sent endpoints it is often the case that connection is closed before Deno flushes body stream. When that happens, following error is thrown:

Uncaught Http: connection closed before message completed
      await requestEvent.respondWith(response);
      ^
    at Object.respondWith (ext:deno_http/01_http.js:336:25)
    at eventLoopTick (ext:core/01_core.js:188:13)
    at async Server.#respond (https://deno.land/[email protected]/http/server.ts:311:7)

I tried to try/catch handler and listen to router 'error' handler but it looks like the error is thrown outside the context of the router.

Is it somehow possible to catch this error and conditionally silence it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions