unjs / unjs/node-mock-http

`useBody` does not work on `unenv` direct call

Open
#8 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17
Forks
4
PR merge metrics
No merged PRs in 30d

Description

I'm not sure if here is the correct place to create an issue, feel to close/move it.

Using h3 useBody with localCall (with unenv) leads to forever waiting promise and as the cause API never return data. (req.on('end') never calls https://github.com/unjs/h3/blob/main/src/utils/body.ts#L27)

As a solution (since unenv set req.body), we can check for req.body inside useBody and use it as parsed body.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at h3's src/utils/body.ts around line 27 and trace how useBody handles requests from unenv localCall. Compare that path with the req.body behavior described in the issue; done means the promise resolves and the parsed body is returned instead of waiting indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.