makeWrappedRootLoader does not handle Response cases
See original GitHub issueIs there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.9.0
Framework Version
React 17.0.2
Link to Sentry event
No response
Steps to Reproduce
- Create a Remix project with a root loader that returns a response object (or uses the Remix provided
json
function).
export const loader: LoaderFunction = async () => {
return json(
{ data_one: [], data_two: "a string" },
{ headers: { 'Cache-Control': 'max-age=300' } }
)
}
- Configure Sentry via
Sentry.init(...)
inentry.server.tsx
- Load the root page in a browser
- Inspect
__remixContext.routeData.root
in dev tools and it will have the shape{ sentryBaggage: string, sentryTrace: string, size: number }
instead of containing the loader data.
This looks to be caused by the makeWrappedRootLoader
function which handles the result of the origLoader
as an Promise<AppData> | AppData
instead of Promise<Response> | Response | Promise<AppData> | AppData
:
function makeWrappedRootLoader(origLoader: DataFunction): DataFunction {
return async function (this: unknown, args: DataFunctionArgs): Promise<Response | AppData> {
const res = await origLoader.call(this, args);
return { ...res, ...getTraceAndBaggage() };
};
}
Expected Result
Data and ResponseInit
settings are propagated when a Promise<Response>
or Response
is returned from the root loader.
Actual Result
Data and headers (or ResponseInit
) data from the root loader are omitted from data on the client and the response respectively.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
HTTP response status codes - MDN Web Docs - Mozilla
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Read more >HTTP/1.1: Status Code Definitions
The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a...
Read more >What could happen if I don't close response.Body?
It is the caller's responsibility to close Body. So there is no finalizers bound to the object and it must be closed explicitly....
Read more >A Guide to HTTP Status Codes - Siteimprove Support
HTTP Response Codes indicate whether specific HTTP requests have been successfully completed. It's an indicator of whether a web page has ...
Read more >Response handling examples | IntelliJ IDEA Documentation
In this topic, we'll examine a couple of HTTP response handling examples. ... client.assert(response.status === 200, "Response status is not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for getting a fix for this. One note, looking at the PR, is that Remix allows for user defined headers to be included in the
Response
that is returned from a loader. Currently by transforming theResponse
into a plain object these settings are lost. The current fix makes sense to unblock anyone that is immediately stuck, but a more complete fix probably looks something like:Hey folks, fix should be released with https://github.com/getsentry/sentry-javascript/releases/tag/7.10.0! Thanks for your patience.