Skip to content

makeWrappedRootLoader does not handle Response cases #5539

Description

@augustuswm

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

  1. Create a Remix project with a root loader that returns a response object (or uses the Remix provided json function).
exportconstloader: LoaderFunction=async()=>{returnjson({data_one: [],data_two: "a string"},{headers: {'Cache-Control': 'max-age=300'}})}
  1. Configure Sentry via Sentry.init(...) in entry.server.tsx
  2. Load the root page in a browser
  3. 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:

functionmakeWrappedRootLoader(origLoader: DataFunction): DataFunction{returnasyncfunction(this: unknown,args: DataFunctionArgs): Promise<Response|AppData>{constres=awaitorigLoader.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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions