-
Notifications
You must be signed in to change notification settings - Fork 125
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
avoid re-instantiating Response
when not required
#902
base: main
Are you sure you want to change the base?
avoid re-instantiating Response
when not required
#902
Conversation
|
ab0c9a9
to
960dc6a
Compare
@@ -131,7 +131,7 @@ export async function runOrFetchBuildOutputItem( | |||
return new Response('Internal Server Error', { status: 500 }); | |||
} | |||
|
|||
return createMutableResponse(resp); | |||
return resp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateResponse
uses this function, but it already does what createMutableResponse
does when needed.
It is also used here packages/next-on-pages/templates/_worker.js/routes-matcher.ts:239
, but since my app is not using middlewares I couldn't test it, npm run test:unit
passes though.
If it is needed there, maybe we can do createMutableResponse
locally for it?
Hopefully my changes are not fundamentally against your design, I just went with common sense based on my very limited knowledge on the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to
if (resp.status === 101) {
return resp;
}
return createMutableResponse(resp);
again this is an attempt to allow websocket connections without knowing much about the codebase, I don't know if it is only status code 101 we should put this exception for, or if it is the correct signal for the exception.
960dc6a
to
a5bc739
Compare
The problem is described here: #894
You may ignore the rest and just read the last comment