Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/http): improve error message when underlying resource of request body unavailable #27463

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Dec 24, 2024

This PR improves the error message when reading request body in Deno.serve and the underlying resource is unavailable.

The error message is currently Bad Resource ID. This PR change it to Cannot read request body as underlying resource unavailable

closes #27133

undefined,
(controller, error) => {
if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error)) {
// TODO(kt3k): We would like to pass `error` as `cause` when BadResource supports it.
Copy link
Member

Choose a reason for hiding this comment

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

Hm, shouldn't this be doable already?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't look so as they are implemented like:

  class BadResource extends Error {
    constructor(msg) {
      super(msg);
      this.name = "BadResource";
    }
  }

https://github.com/denoland/deno_core/blob/8d7bfea48ebfcaee989f8d72b243fb09302014f9/core/01_core.js#L302-L305

Copy link
Member Author

Choose a reason for hiding this comment

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

Created an issue in deno_core denoland/deno_core#1031

@kt3k kt3k merged commit 9ad0d4c into denoland:main Jan 6, 2025
17 checks passed
@kt3k kt3k deleted the ext-http-better-request-body-error branch January 6, 2025 07:12
dsherret pushed a commit that referenced this pull request Jan 9, 2025
…est body unavailable (#27463)

The error message is currently `Bad Resource ID`. This commit changes it to
`Cannot read request body as underlying resource unavailable`

closes #27133
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.

Inconsistent Handling of TCP Stream Closure Causes BadResource Error in Deno
2 participants