SSR: avoid sending new response when headers were already sent - #4733
Conversation
tdonohue
left a comment
There was a problem hiding this comment.
👍 Thanks @danielcoelhocgu ! I see this small fix has had a lot of positive feedback in #2315. I gave it a try myself as well, and it seems to reduce the number of warnings (with no obvious side effects). I'll merge this immediately and attempt to auto-backport to 7.x, 8.x and 9.x
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin dspace-7_x
git worktree add -d .worktree/backport-4733-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-4733-to-dspace-7_x
git switch --create backport-4733-to-dspace-7_x
git cherry-pick -x 951c5f69d46db57efb5423c4581b4c895793c6dd |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
|
UPDATE: This could not be automatically backported to 7.6.x, as the code in However, this has been backported automatically to 8.x and 9.x and will be fixed in the next maintenance releases for those versions. |
References
Fixes #2315
Description
This PR solves a problem that resulted in the following warning message in logs:
This seems to happen when frontend redirects a request. For example when accessing a permanent URI (
/handle/XXX/YYY). Although redirect works in most cases, in our particular infrastructure on AWS it causes an error message to be displayed to the user.Instructions for Reviewers
I added a check in SSR main render function in order to avoid sending more content when HTTP headers were already sent in the same request.
To test it, make sure SSR is active and access a collection or item page using a permanent URI. Verify the logs to see if the warning message is present or not.
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.