Hey community,
So I tried the following:
-
Create a page with id "test"
-
Rename that page to id "test2"
-
Browser /test
In debug mode, I got an error 500 on the first call (document) so I guess it was something that failed on the server. And then a redirect is performed to test2
In production mode, the error is generated and nothing more happens.
GET http://localhost:3005/test 500 (Internal Server Error)
Environment:
-
Volto 17.12.1 generated with generator-volto 8.1.3
-
Plone 6.0.9 with plone.restapi 9.2.1
When I try this on the demo site it works well: https://demo.plone.org/test
So I tried to delete all addons of my project and change volto version to 17.15.5 but the same behavior as before.
On debugging, putting some console logs here and there, I found that the error on middleware is the following:
error in middleware TypeError: Cannot read properties of undefined (reading 'actions')
at actions ({...}/node_modules/@plone/volto/src/reducers/actions/actions.js:53:1)
Then after more debugging, in src/middleware/storeProtectLoadUtils.js
I found that first the test2
object info is obtained in:
{ subrequest: null, result: {INFO test-2 object}, type: 'GET_CONTENT_SUCCESS' }
but later, another action with an empty result is executed which produces the error on the reducers (on action reducer and if I modify that reducer, in breadcrumbs and so on)
{ subrequest: null, result: {}, type: 'GET_CONTENT_SUCCESS' }
Any idea what is going wrong on here and why this is not happening on the demo site?
I will try to create a fresh environment with volto 15.15.5 and see if that's still happening.
Meanwhile, I made this change in src/middleware/storeProtectLoadUtils.js
which feels super hacky but avoids the error on the reducers and thus the redirect is made in production mode aswell
export const protectLoadEnd =
[...]
if (action?.type === 'GET_CONTENT_SUCCESS' && Object.keys(action?.result).length === 0) {
return
}
return next(action);
};