Compare commits

...

5 Commits

Author SHA1 Message Date
Claude Bot
9820a8fe95 fix: hoist remaining closures from kDoFetch and setTimeout to module scope
- Extract .then(response => ...) to module-scope onFetchResponse + .bind
- Extract handleResponse closure to module-scope handleFetchResponse + .bind
- Extract res.setTimeout closure to module-scope resSetTimeout function
- Extract res timeout timer to module-scope resTimeoutFired (uses
  setTimeout's extra args to pass res/callback without closure)
- Extract .catch() to module-scope onFetchError + .bind
- Extract .finally() to module-scope onFetchFinally + .bind (keepOpen
  moved to instance property kKeepOpen)
- Extract prototype setTimeout timer to module-scope onRequestTimeout + .bind
- Store fetch response on instance via kResponse symbol

The only closures remaining are:
- DNS lookup callback (external API requires callback)
- iterate() for happy eyeballs (captures mutable candidates array)
- Async generator body (generators have their own this)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 03:19:47 +00:00
Claude Bot
3ccbda5138 fix: eliminate remaining closures in ClientRequest
- Replace per-instance no-op closures (kResolveNextChunk, kHandleResponse,
  kOnEnd initializers) with shared module-scope noop function
- Extract `(s, e) => s.emit("error", e)` closures to module-scope
  emitErrorNT function
- Extract `fail()` closure from DNS lookup callback to module-scope
  emitLookupError function

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 03:11:33 +00:00
Claude Bot
cdc05d0ec8 fix: use symbol keys for internal methods, replace closures with .bind
- All internal prototype methods now use Symbol keys instead of string
  keys (e.g., _writeInternal -> [kWriteInternal]) so they are not
  user-observable
- Replace signal abort closure with onSignalAbort.bind(this)
- Replace _send's onEnd closure with onEndCallHandleResponse.bind(this)
- Replace _onAbort.bind(this) with [kOnAbort].bind(this)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 03:03:37 +00:00
Claude Bot
1c5f27a0b7 fix: remove unused local port variable in ClientRequest constructor
Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 02:48:19 +00:00
Claude Bot
727b1b820a refactor(http): hoist ClientRequest closures to prototype/module scope
Move all ~30 closures from inside the ClientRequest constructor to
prototype methods and module-scope helpers. This eliminates closure
captures of the parent scope, reducing memory per-instance and
improving JIT optimization.

- Convert instance method assignments (write, end, destroy, flushHeaders,
  abort, _ensureTls, setSocketKeepAlive, setNoDelay, kClearTimeout) to
  prototype methods
- Convert internal helpers (maybeEmitSocket/Prefinish/Finish/Close,
  socketCloseListener, onAbort, pushChunk, write_, send, startFetch)
  to prototype methods with _ prefix
- Extract getURL and emitResponseNT as module-scope functions
- Replace closure variables (fetching, writeCount, resolveNextChunk,
  handleResponse, onEnd) with symbol-keyed instance properties
- Drop the no-op oldEnd capture (OutgoingMessage.prototype.end is a stub)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 02:29:04 +00:00

File diff suppressed because it is too large Load Diff