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

fix(remix): Pass loadContext through wrapped document request function #8268

Merged
merged 4 commits into from Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/remix/src/utils/instrumentServer.ts
Expand Up @@ -113,14 +113,15 @@ function makeWrappedDocumentRequestFunction(
responseStatusCode: number,
responseHeaders: Headers,
context: Record<symbol, unknown>,
loadContext: Record<string, unknown>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be optional as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be. I'll fix it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be. I've pushed a fix for that and the formatting. Sorry for the delay fixing the formatting - I was having trouble getting the repo tooling to work because I'd been using the wrong version of yarn, so it took a while to work out what was wrong.

): Promise<Response> {
let res: Response;

const activeTransaction = getActiveTransaction();
const currentScope = getCurrentHub().getScope();

if (!currentScope) {
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context, loadContext);
}

try {
Expand All @@ -133,7 +134,7 @@ function makeWrappedDocumentRequestFunction(
},
});

res = await origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
res = await origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context, loadContext);

span?.finish();
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/src/utils/types.ts
Expand Up @@ -127,7 +127,7 @@ export interface ServerBuild {
}

export interface HandleDocumentRequestFunction {
(request: RemixRequest, responseStatusCode: number, responseHeaders: Headers, context: EntryContext):
(request: RemixRequest, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext?: AppLoadContext):
| Promise<Response>
| Response;
}
Expand Down