-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
makeWrappedRootLoader does not handle Response cases #5539
Comments
Thanks a lot for reporting this @augustuswm! Opened a PR to fix this 👍 |
@augustuswm @massimopalmieri Thank you for the bug reports! The fix for this will be included in the next release (next 1-2 days)! |
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 function makeWrappedRootLoader(origLoader: DataFunction): DataFunction {
return async function (this: unknown, args: DataFunctionArgs): Promise<Response | AppData> {
const res = await origLoader.call(this, args);
const traceAndBaggage = getTraceAndBaggage();
// Note: `redirect` and `catch` responses do not have bodies to extract
if (isResponse(res) && !isRedirectResponse(res) && !isCatchResponse(res)) {
const data = await extractData(res);
if (typeof data === 'object') {
// A new response needs to be constructed as the original body can not be replaced
return new Response(
JSON.stringify({ ...data, ...traceAndBaggage }),
{ status: res.status, statusText: res.statusText, headers: res.headers }
);
} else {
__DEBUG_BUILD__ && logger.warn('Skipping injection of trace and baggage as the response body is not an object');
// Return the response as-is without any changes
return res;
}
}
return { ...res, ...traceAndBaggage };
};
} |
Hey @augustuswm, great suggestion - will use that! |
Hey folks, fix should be released with https://github.com/getsentry/sentry-javascript/releases/tag/7.10.0! Thanks for your patience. |
Hi, I'm finding this is still occurring for me on Remix when I return a
Here the redirect fails to execute and I get an error stating that user is undefined in the root Interestingly, other redirects I have in route loaders seem to work fine. This is on version 7.44.2, implemented as suggested in the documentation. |
Is there an existing issue for this?
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
json
function).Sentry.init(...)
inentry.server.tsx
__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 theorigLoader
as anPromise<AppData> | AppData
instead ofPromise<Response> | Response | Promise<AppData> | AppData
:Expected Result
Data and
ResponseInit
settings are propagated when aPromise<Response>
orResponse
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.The text was updated successfully, but these errors were encountered: