{"record":{"id":"c9e871f77ae515f7","repo":"facebook/react","slug":"cannot-await-or-return-from-a-thenable-you-cannot","errorCode":null,"errorMessage":"Cannot await or return from a thenable. You cannot await a client module from a server component.","messagePattern":"Cannot await or return from a thenable\\. You cannot await a client module from a server component\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js","lineNumber":190,"sourceCode":"      // React looks for debugInfo on thenables.\n      case '_debugInfo':\n        return undefined;\n      // Avoid this attempting to be serialized.\n      case 'toJSON':\n        return undefined;\n      case Symbol.toPrimitive:\n        // $FlowFixMe[prop-missing]\n        return Object.prototype[Symbol.toPrimitive];\n      case Symbol.toStringTag:\n        // $FlowFixMe[prop-missing]\n        return Object.prototype[Symbol.toStringTag];\n      case 'Provider':\n        // Context.Provider === Context in React, so return the same reference.\n        // This allows server components to render <ClientContext.Provider>\n        // which will be serialized and executed on the client.\n        return receiver;\n      case 'then':\n        throw new Error(\n          `Cannot await or return from a thenable. ` +\n            `You cannot await a client module from a server component.`,\n        );\n    }\n    // eslint-disable-next-line react-internal/safe-string-coercion\n    const expression = String(target.name) + '.' + String(name);\n    throw new Error(\n      `Cannot access ${expression} on the server. ` +\n        'You cannot dot into a client module from a server component. ' +\n        'You can only pass the imported name through.',\n    );\n  },\n  set: function () {\n    throw new Error('Cannot assign to a client module from a server module.');\n  },\n};\n\nfunction getReference(target: Function, name: string | symbol): $FlowFixMe {","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-turbopack/src/ReactFlightTurbopackReferences.js#L172-L208","documentation":"In the turbopack RSC runtime, client module exports become deep Proxies on the server. The get trap intercepts 'then' because if a thenable escaped, React would treat the client reference as a promise and try to await it server-side; client code cannot execute on the server, so awaiting or returning a client module from a server component throws.","triggerScenarios":"`await clientModule.someExport` inside a server component, returning the reference from an async server component, or routing it through Promise.resolve()/a .then() chain in server code.","commonSituations":"Importing a helper from a 'use client' file and awaiting it in RSC; shared isomorphic modules that await their imports; utility modules accidentally marked 'use client'.","solutions":["Do the awaiting on the server with plain server modules and pass the results as props","If the awaited value must come from client code, move the await into a client component or effect","Audit 'use client' boundaries: async data helpers used by server components must live in server modules"],"exampleFix":"// before (server component)\nimport {getUser} from './user-client'; // 'use client'\nexport default async function Page() {\n  const user = await getUser(); // Error: cannot await a client module\n}\n\n// after\nimport {getUser} from './user-server'; // plain server module\nexport default async function Page() {\n  const user = await getUser();\n  return <UserCard user={user} />;\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const CLIENT_REFERENCE = Symbol.for('react.client.reference');\nfunction isClientReference(value) {\n  return (\n    (typeof value === 'object' || typeof value === 'function') &&\n    value !== null &&\n    value.$$typeof === CLIENT_REFERENCE\n  );\n}\n// server component:\nif (isClientReference(mod)) {\n  throw new Error('Pass this reference through; do not await it');\n}","tryCatchPattern":null,"preventionTips":["Keep async data helpers in server modules; client modules export only components and handlers","Never await an import that crosses a 'use client' boundary","Review shared isomorphic utils for hidden client-boundary imports"],"tags":["react-server-components","turbopack","client-references","use-client","await"],"backgroundTag":"rsc-client-server-boundary","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}