Skip to content

Commit 2e472e8

Browse files
committed
fix(readRawBody): resolve cached promise before normalizing buffer
closes #369
1 parent a6ccd2c commit 2e472e8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/utils/body.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ export function readRawBody<E extends Encoding = "utf8">(
3030
(event.node.req as any)[RawBodySymbol] ||
3131
(event.node.req as any).body; /* unjs/unenv #8 */
3232
if (_rawBody) {
33-
const promise = Promise.resolve(
34-
Buffer.isBuffer(_rawBody) ? _rawBody : Buffer.from(_rawBody)
35-
);
33+
const promise = Promise.resolve(_rawBody)
34+
.then(_resolved => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved))
3635
return encoding
3736
? promise.then((buff) => buff.toString(encoding))
3837
: (promise as Promise<any>);

0 commit comments

Comments
 (0)