Home / Function/ callServer() — react Function Reference

callServer() — react Function Reference

Architecture documentation for the callServer() function in index.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ed786118_418e_b032_130b_4222b0664687["callServer()"]
  856b3a4c_6a24_b2e9_eb47_87b4757da255["index.js"]
  ed786118_418e_b032_130b_4222b0664687 -->|defined in| 856b3a4c_6a24_b2e9_eb47_87b4757da255
  d4550c74_c044_ca05_74c0_f2722e08bb76["createWebSocketStream()"]
  ed786118_418e_b032_130b_4222b0664687 -->|calls| d4550c74_c044_ca05_74c0_f2722e08bb76
  style ed786118_418e_b032_130b_4222b0664687 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fixtures/flight/src/index.js lines 55–100

async function callServer(id, args) {
  let response;
  if (process.env.NODE_ENV === 'development') {
    const requestId = crypto.randomUUID();
    const debugChannel = await createWebSocketStream(
      `ws://localhost:3001/debug-channel?id=${requestId}`
    );
    response = createFromFetch(
      fetch('/', {
        method: 'POST',
        headers: {
          Accept: 'text/x-component',
          'rsc-action': id,
          'rsc-request-id': requestId,
        },
        body: await encodeReply(args),
      }),
      {
        callServer,
        debugChannel,
        findSourceMapURL,
      }
    );
  } else {
    response = createFromFetch(
      fetch('/', {
        method: 'POST',
        headers: {
          Accept: 'text/x-component',
          'rsc-action': id,
        },
        body: await encodeReply(args),
      }),
      {
        callServer,
        findSourceMapURL,
      }
    );
  }
  const {returnValue, root} = await response;
  // Refresh the tree with the new RSC payload.
  startTransition(() => {
    updateRoot(root);
  });
  return returnValue;
}

Domain

Subdomains

Frequently Asked Questions

What does callServer() do?
callServer() is a function in the react codebase, defined in fixtures/flight/src/index.js.
Where is callServer() defined?
callServer() is defined in fixtures/flight/src/index.js at line 55.
What does callServer() call?
callServer() calls 1 function(s): createWebSocketStream.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free