Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error thrown while listing Headers with single-fetch response stub in production build #9802

Closed
GuptaSiddhant opened this issue Jul 29, 2024 · 1 comment

Comments

@GuptaSiddhant
Copy link

GuptaSiddhant commented Jul 29, 2024

Reproduction

  • Create a new basic remix app with cmd npx create-remix@latest.
  • Enable single-fetch in vite.config.ts: unstable_singleFetch: true,
  • Attempt to call response.headers.entries() in the loader of index route _index.tsx. I added the following loader to the route to check for listing headers:
// loader for _index.tsx
export const loader: LoaderFunction = ({ response }) => {
  if (!response) return null;

  console.log("response is defined.");
  response.headers.append("Location", "https://remix.run");

  console.log("response has following headers:");
  for (const header of response.headers.entries()) {
    console.log(header);
  }
  return null;
};

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M2 Pro
    Memory: 198.59 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v20.11.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 8.8.0 - ~/.nvm/versions/node/v20.11.0/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.185
    Edge: 127.0.2651.74
    Safari: 17.5
    Safari Technology Preview: 18.0
  npmPackages:
    @remix-run/dev: ^2.10.3 => 2.10.3 
    @remix-run/node: ^2.10.3 => 2.10.3 
    @remix-run/react: ^2.10.3 => 2.10.3 
    @remix-run/serve: ^2.10.3 => 2.10.3 
    vite: ^5.1.0 => 5.3.5

Used Package Manager

npm

Expected Behavior

Running the app both in development (npm run dev) and production (npm run build; npm run start) mode should list the headers from the Response Stub.

Console output for above mentioned loader:

response is defined.
response has following headers:
[ 'location', 'https://remix.run' ]

Actual Behavior

Running the app in development mode (npm run dev) will not throw any errors and will log the headers correctly. But when running in production mode (npm run build; npm run start), the same route will throw error.

Error thrown in the production build for index route using loader mentioned above:

[remix-serve] http://localhost:3000 (http://192.168.1.96:3000)
response is defined.
response has following headers:
TypeError: Cannot read private member #headersList from an object whose class did not declare it
    at Proxy.get [headers map sorted] (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/undici/lib/web/fetch/headers.js:550:14)
    at Reflect.get (<anonymous>)
    at Object.get (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/server-runtime/dist/single-fetch.js:289:22)
    at FastIterableIterator.next (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/undici/lib/web/fetch/util.js:870:34)
    at loader (file:///Users/siddhant.c.gupta/Projects/GS/remix-sf/build/server/index.js?t=1722288481604.003:139:14)
    at Object.callRouteLoader (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/server-runtime/dist/data.js:66:22)
    at handler (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/server-runtime/dist/routes.js:54:39)
    at actualHandler (/Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/router/router.ts:4803:14)
    at /Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/router/router.ts:4815:58
    at /Users/siddhant.c.gupta/Projects/GS/remix-sf/node_modules/@remix-run/server-runtime/dist/single-fetch.js:57:90

In any case the output of both development and production builds should be the same. Either both should throw error or both should list the headers.

@brophdawg11
Copy link
Contributor

The response stub will be going away in the next release (#9769) so this will be a moot point then as we won't have a Proxy around Headers anymore

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants