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

Loader header are null if the loader uses defer #5345

Closed
1 task done
dpobel opened this issue Feb 2, 2023 · 2 comments
Closed
1 task done

Loader header are null if the loader uses defer #5345

dpobel opened this issue Feb 2, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@dpobel
Copy link

dpobel commented Feb 2, 2023

What version of Remix are you using?

1.11.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

I followed https://remix.run/docs/en/v1/route/headers and https://remix.run/docs/en/v1/guides/streaming but it looks like retrieving the headers sent by loader from headers does not work when the loader uses a defer (with json it works perfectly)

To reproduce use the following route:

import React from "react";
import { defer, json } from "@remix-run/node";

export const loader = async ({ params, context }) => {
  // with json, no problem
  // return json(
  // with defer, in `headers`, `loaderHeaders.get("x-custom-header-from-loader")`
  // returns null.
  return defer(
    { whatever: "stuff" },
    {
      headers: {
        "x-custom-header-from-loader": "value from loader",
      },
    }
  );
};

export const headers = ({ loaderHeaders }) => {
  console.log(
    "Header from loader",
    loaderHeaders.get("x-custom-header-from-loader")
  );
  return {
    "x-customer-header": loaderHeaders.get("x-custom-header-from-loader"),
  };
};

export default function BugHeader() {
  return <p>Bug header?</p>;
}

Expected Behavior

in headers, loaderHeaders.get("myheader") should return the value set in loader

Actual Behavior

it seems loaderHeaders.get("myheader") always return null

@zackify
Copy link

zackify commented Feb 8, 2023

can confirm, just check the browser and no response headers are sent. Switch to json, and they are

@brophdawg11 brophdawg11 added bug Something isn't working and removed bug:unverified labels Feb 9, 2023
@brophdawg11 brophdawg11 self-assigned this Feb 9, 2023
@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Feb 10, 2023
@brophdawg11
Copy link
Contributor

This should be fixed in 1.14.0

@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label Mar 1, 2023
@brophdawg11 brophdawg11 removed their assignment Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants