b310-digital / teammapper

Mindmapping made simple: Host and create your own mindmaps. Share your mindmap sessions with your team and collaborate on mindmaps.
https://teammapper.org
MIT License
202 stars 16 forks source link

Error in logs appear when deleting a map #297

Open JannikStreek opened 1 week ago

JannikStreek commented 1 week ago

Describe the bug When a map is deleted, this error shows up in the console:

[0] [Nest] 123  - 06/20/2024, 8:56:08 AM   ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'name')
[0] TypeError: Cannot read properties of undefined (reading 'name')
[0]     at /home/node/app/teammapper-backend/src/map/controllers/maps.controller.ts:25:13
[0]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[0]     at MapsController.findOne (/home/node/app/teammapper-backend/src/map/controllers/maps.controller.ts:24:17)
[0]     at /home/node/app/teammapper-backend/node_modules/@nestjs/core/router/router-execution-context.js:46:28
[0]     at /home/node/app/teammapper-backend/node_modules/@nestjs/core/router/router-proxy.js:9:17

Everything else works as expected. But we don't need to raise an error for something that actually worked.

To Reproduce Steps to reproduce the behavior:

  1. Create a new map
  2. Delete map
  3. See console

Expected behavior No errors are thrown when deleting a map.

sorenjohanson commented 1 week ago

Seems like he's trying to access the map again after redirect for some reason:

http.service.ts:19 GET https://4200.code.soeren.codes/api/maps/e650c758-87e3-4bbb-9098-9330b6d395bc 500 (Internal Server Error)

sorenjohanson commented 1 week ago

Actually, this will be fixed in #288. When deleting the map, it calls window.location.reload(), which obviously just tries to access a non-existant map. Since we're reworking the method to add a toast when deleting anyway, we might as well fix it in there by redirecting to / instead of calling window.location.reload().

sorenjohanson commented 1 week ago

This is fixed in latest main.

JannikStreek commented 1 week ago

looks good. I would expand the issue a bit: If a map is deleted and later accessed with the old (deleted) uuid by the user, I can see this is in the logs:

[0] [Nest] 511  - 06/24/2024, 1:05:13 PM   ERROR [WsExceptionsHandler] undefined
[0] [Nest] 511  - 06/24/2024, 1:05:13 PM   ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'name')
[0] TypeError: Cannot read properties of undefined (reading 'name')
[0]     at /home/node/app/teammapper-backend/src/map/controllers/maps.controller.ts:25:13
[0]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[0]     at MapsController.findOne (/home/node/app/teammapper-backend/src/map/controllers/maps.controller.ts:24:17)
[0]     at /home/node/app/teammapper-backend/node_modules/@nestjs/core/router/router-execution-context.js:46:28
[0]     at /home/node/app/teammapper-backend/node_modules/@nestjs/core/router/router-proxy.js:9:17

Exception is fine, but it should state that the map is not existing. In addition, the user is redirected correctly to the start page but a toast is missing that the map does not exist.

sorenjohanson commented 1 week ago

I think that's a more general issue of not good enough error handling when accessing a non-existant map - I imagine the same thing happens when trying to access /map/abcdefgh. Maybe a separate issue and PR is better?