From 0abd16731990a144fe2147395d08ee0814090706 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 12 Mar 2026 14:41:36 +0900 Subject: [PATCH 1/2] perf(request): cache method key --- src/request.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/request.ts b/src/request.ts index d83fb53..67c29f7 100644 --- a/src/request.ts +++ b/src/request.ts @@ -121,6 +121,7 @@ const getRequestCache = Symbol('getRequestCache') const requestCache = Symbol('requestCache') const incomingKey = Symbol('incomingKey') const urlKey = Symbol('urlKey') +const methodKey = Symbol('methodKey') const headersKey = Symbol('headersKey') export const abortControllerKey = Symbol('abortControllerKey') export const getAbortController = Symbol('getAbortController') @@ -366,7 +367,7 @@ const readBodyDirect = (request: Record): Promise const requestPrototype: Record = { get method() { - return normalizeIncomingMethod(this[incomingKey].method) + return (this[methodKey] ||= normalizeIncomingMethod(this[incomingKey].method)) }, get url() { From 78884e895f48896e9f7450cbc661d18fe14f2e9d Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Fri, 13 Mar 2026 06:24:25 +0900 Subject: [PATCH 2/2] refactor Co-authored-by: Taku Amano --- src/request.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/request.ts b/src/request.ts index 67c29f7..f88b98e 100644 --- a/src/request.ts +++ b/src/request.ts @@ -367,7 +367,7 @@ const readBodyDirect = (request: Record): Promise const requestPrototype: Record = { get method() { - return (this[methodKey] ||= normalizeIncomingMethod(this[incomingKey].method)) + return this[methodKey] }, get url() { @@ -536,6 +536,7 @@ export const newRequest = ( ) => { const req = Object.create(requestPrototype) req[incomingKey] = incoming + req[methodKey] = normalizeIncomingMethod(incoming.method) const incomingUrl = incoming.url || ''