strapi-middleware-cache
strapi-middleware-cache copied to clipboard
TypeError: Cannot read property 'kind' of undefined
i'm getting 500 errors submitting posts to strapi because this extension seems to be choking on the unique id field
[2021-08-02T03:03:18.800Z] debug GET /content-manager/collection-types/application::posts.posts?page=1&pageSize=20&_sort=date:DESC (97 ms) 200
[2021-08-02T03:03:24.820Z] debug POST /content-manager/uid/generate (88 ms) 200
[2021-08-02T03:03:26.405Z] debug POST /content-manager/uid/generate (48 ms) 200
[2021-08-02T03:03:26.950Z] debug POST /content-manager/uid/check-availability (35 ms) 200
TypeError: Cannot read property 'kind' of undefined
at /workspace/node_modules/strapi-middleware-cache/lib/index.js:195:51
at /workspace/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/workspace/node_modules/lodash/lodash.js:3032:24)
at /workspace/node_modules/lodash/lodash.js:4936:18
at Function.forEach (/workspace/node_modules/lodash/lodash.js:9410:14)
at clearCache (/workspace/node_modules/strapi-middleware-cache/lib/index.js:194:13)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /workspace/node_modules/strapi-middleware-cache/lib/index.js:248:9
at async bustAdmin (/workspace/node_modules/strapi-middleware-cache/lib/index.js:318:11)
at async /workspace/node_modules/strapi/lib/middlewares/responses/index.js:9:9
at async cors (/workspace/node_modules/@koa/cors/index.js:95:16)
at async /workspace/node_modules/strapi/lib/middlewares/logger/index.js:56:11
at async /workspace/node_modules/strapi/lib/middlewares/responseTime/index.js:17:9
at async /workspace/node_modules/strapi/lib/services/metrics/middleware.js:29:5
at async /workspace/node_modules/strapi/lib/Strapi.js:325:9
I'm getting the exact same error when I have clearRelatedCache: true
(I also have a uid field in my model)
If i disable clearRelatedCache everything is fine.
"dependencies": {
"axios": "^0.21.4",
"csv": "^5.5.0",
"fast-xml-parser": "^3.20.0",
"he": "^1.2.0",
"knex": "0.21.18",
"pg": "8.5.1",
"strapi": "3.6.8",
"strapi-admin": "3.6.8",
"strapi-connector-bookshelf": "3.6.8",
"strapi-middleware-cache": "^1.5.0",
"strapi-middleware-upload-plugin-cache": "^1.1.1",
"strapi-plugin-content-manager": "3.6.8",
"strapi-plugin-content-type-builder": "3.6.8",
"strapi-plugin-documentation": "3.6.8",
"strapi-plugin-email": "3.6.8",
"strapi-plugin-email-designer": "latest",
"strapi-plugin-entity-relationship-chart": "^3.1.0",
"strapi-plugin-graphql": "3.6.8",
"strapi-plugin-i18n": "3.6.8",
"strapi-plugin-import-export-content": "jpizzle34/strapi-plugin-import-export-content#export-all-option",
"strapi-plugin-upload": "3.6.8",
"strapi-plugin-users-permissions": "3.6.8",
"strapi-provider-email-amazon-ses": "^3.6.8",
"strapi-utils": "3.6.8"
}
Hey @selfagency and @jpizzle34
I've had a look at the code, it does seem to be an issue in version 1 of the middleware. That said the code has been completely reworked in the v2 (beta branch). Upgrading to it might solve this issue for you
npm install --save [email protected]
(note, configuration format has evolved a bit since and might require some changes when you do upgrade)