Closed
Description
Is 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?
@sentry/remix
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.