React 19 / Next.js 15 – Runtime “Connection closed” error on Netlify but not locally

Hi everyone,

I’m running into a deployment/runtime issue that only appears on Netlify.

  • Frameworks: Next.js 15 (React 19)

  • Adapter: Using the Netlify Next.js runtime (not legacy plugin)

  • Local behavior:

    • Works fine in dev (next dev).

    • Works fine when building a production build locally (next build && next start).

  • Netlify behavior:

    • Build succeeds, but at runtime I get errors like:

      hook.js:608 Error: Connection closed.
          at t (react-server-dom-web…roduction.js:1700:1)
      overrideMethod @ hook.js:608
      hook.js:608 Global error: Error: Connection closed.
      
      

      These happen during navigation, from the RSC stream (__flight__ request).

    • Edge function logs show no errors.

    • However, I do get errors from regular functions, for example:

      Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
      Unhandled Promise Rejection  {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"SyntaxError: Unexpected token 'export'"}
      
      /var/task/node_modules/gsap/SplitText.js:310
      export { SplitText, SplitText as default };
      ^^^^^^
      SyntaxError: Unexpected token 'export'
      
      

      Stack trace points into .next/server/.../page.js where SplitText is imported.

The only change between the last successful deploy and this error is my latest commit. I’ve gone through the diff, but can’t see anything that should break only on Netlify. Since the app runs cleanly in local production mode, I suspect something Netlify-specific (runtime mismatch, bundling/ESM issue, or adapter problem).

What I’ve tried so far:

  • Verified build completes successfully.

  • Confirmed local production build works.

  • Checked for Node-only API calls in middleware.ts.

  • Looked at Netlify function logs (see above).

Questions:

  • Could this be related to Netlify’s runtime handling of ESM packages (like GSAP’s SplitText export)?

  • Any known issues with Next.js 15 + React 19 on the current Netlify runtime where RSC streams close unexpectedly?

  • Is there a recommended way to force certain dependencies (like GSAP) to be bundled/transpiled to avoid the Unexpected token 'export' error in Netlify Functions?

Any guidance would be greatly appreciated. I’m happy to provide deploy IDs or further logs if needed.

Thanks in advance!

Would you be able to create a minimal reproduction?