Skip to content

remix/node-hmr · Function

View Source

createHmrReadyFetch

Summary

Wraps a fetch handler so requests wait for the current HMR generation to be ready.

If the wrapped fetch handler returns a retryable response or throws a retryable error, the request is attempted again only when the runner moved to a new generation while the request was in flight.

Signature

function createHmrReadyFetch(
  runner: NodeHmrRunner,
  fetch: (request: Request) => Response | Promise<Response>,
  options: HmrReadyFetchOptions,
): (request: Request) => Promise<Response>

Parameters

runner

HMR runner that controls server readiness.

fetch

Fetch handler to call once the runner is ready.

options

Retry behavior for responses and thrown errors.

Returns

A fetch handler that waits for HMR readiness before forwarding requests.