strapi-plugin-record-locking icon indicating copy to clipboard operation
strapi-plugin-record-locking copied to clipboard

Bug: TypeError: Cannot read properties of undefined (reading 'query')

Open mstroiu opened this issue 2 years ago • 1 comments

Hi there,

I've stumbled across this type of error while generating the types using npm run strapi ts:generate-types --verbose and I'm not sure if I'm doing something wrong or if is a real bug.

Output:

npm run strapi ts:generate-types --verbose
npm verb cli /.nvm/versions/node/v20.10.0/bin/node /Users/*****/.nvm/versions/node/v20.10.0/bin/npm
npm info using [email protected]
npm info using [email protected]
npm verb title npm run strapi ts:generate-types
npm verb argv "run" "strapi" "ts:generate-types" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/.npm/_logs/2024-02-07T19_34_38_766Z-
npm verb logfile /.npm/_logs/2024-02-07T19_34_38_766Z-debug-0.log

> [email protected] strapi
> strapi ts:generate-types

Starting the compilation for TypeScript files in ***********/************/*********/***
[INFO]  [2024-02-07T19:34:42.749Z] (Typegen) Starting the type generation process
[INFO]  [2024-02-07T19:34:42.749Z] (Typegen) Generating types for contentTypes
(node:76434) Warning: The upload provider "strapi-provider-upload-static-service" doesn't implement the uploadStream function. Strapi will fallback on the upload method. Some performance issues may occur.
(Use `node --trace-warnings ...` to show where the warning was created)
[INFO]  [2024-02-07T19:34:42.971Z] (Typegen) Generating types for components
[INFO]  [2024-02-07T19:34:43.077Z] (Typegen) Saved contentTypes types in ../../../../../types/generated/contentTypes.d.ts
[INFO]  [2024-02-07T19:34:43.077Z] (Typegen) Saved components types in ../../../../../types/generated/components.d.ts
[INFO]  [2024-02-07T19:34:43.077Z] (Typegen) The task completed successfully with 0 warning(s) and 0 error(s) in 0.328s.
/node_modules/@notum-cz/strapi-plugin-record-locking/server/destroy.js:7
  strapi.db.query("plugin::record-locking.open-entity").deleteMany();
            ^

TypeError: Cannot read properties of undefined (reading 'query')
    at module.exports [as destroy] (node_modules/@notum-cz/strapi-plugin-record-locking/server/destroy.js:7:13)
    at Object.destroy (/node_modules/@strapi/strapi/lib/core/domain/module/index.js:54:45)
    at Object.destroy (/node_modules/@strapi/strapi/lib/core/registries/modules.js:38:19)
    at async Strapi.runLifecyclesFunctions (/node_modules/@strapi/strapi/lib/Strapi.js:546:5)
    at async Strapi.destroy (/node_modules/@strapi/strapi/lib/Strapi.js:231:5)

Node.js v20.10.0
npm verb exit 1
npm verb code 1

I'm using the following dependencies

  • @notum-cz/strapi-plugin-record-locking version 1.6.6
  • typescript version 4.9.5
  • @strapi/strapi version 4.10.5
  • @strapi/utils version 4.9.0

Let me know if you need more information

Thank you

mstroiu avatar Feb 07 '24 19:02 mstroiu

Similar to my issue here: https://github.com/notum-cz/strapi-plugin-record-locking/issues/83, seems like a general CLI use case issue?

broksonic21 avatar Apr 04 '24 12:04 broksonic21

Thank you for reporting this. I have fixed this by adding optional chaining in https://github.com/notum-cz/strapi-plugin-record-locking/commit/afd8b915d10b7da9b93290c59bf4cfd9c1d71b04 and will release new version.

omikulcik avatar Jun 12 '24 09:06 omikulcik