KayelGee / token-attacher

MIT License
12 stars 18 forks source link

Deleting a base token with multiple nested prefabs on the same level will only visually delete everything properly #51

Closed KayelGee closed 3 years ago

tjlanza commented 3 years ago

I'm having trouble understanding this issue title, but I'm wondering if it's creating what appears to be an MLT error. Is this meant to say "Deleting a token with multiple attachments only deletes the visual aspect, but leaves other elements of the data in the scene"?

The other day, I had a session where I used a few TA elements (vehicles with two people attached to them). They spawned okay, but I didn't end up using them, so I deleted them. I didn't notice anything during the game session, but when I came back to it the next day to do some GM work, any time I change scenes I get the below error messages.

They go away when I disable MLT, but they only appeared after using and deleting TA-using objects.

image

foundry.js:1246 Uncaught (in promise) Error: The key hdrlKOOmOgg6rSwJ does not exist in the EmbeddedCollection Collection
[No packages detected]
    at Map.get (/home/foundry/hexagon/server/resources/app/common/utils/collection.mjs:106)
    at ServerDatabaseBackend._deleteEmbeddedDocuments (/home/foundry/hexagon/server/resources/app/dist/database/backend/server-backend.mjs:1)
    at async Socket.handleEvent (/home/foundry/hexagon/server/resources/app/dist/server/sockets.mjs:1)
_handleError @ foundry.js:1246
(anonymous) @ foundry.js:1230
value @ socket.js:305
value @ socket.js:228
r.emit @ index.js:145
value @ typed-events.js:59
value @ manager.js:214
r.emit @ index.js:145
value @ index.js:120
value @ manager.js:206
r.emit @ index.js:145
value @ socket.js:416
r.emit @ index.js:145
value @ transport.js:107
value @ transport.js:100
ws.onmessage @ websocket.js:112
foundry.js:1246 Uncaught (in promise) Error: The key J7Dzuf5Z7xSinLxR does not exist in the EmbeddedCollection Collection
[No packages detected]
    at Map.get (/home/foundry/hexagon/server/resources/app/common/utils/collection.mjs:106)
    at ServerDatabaseBackend._deleteEmbeddedDocuments (/home/foundry/hexagon/server/resources/app/dist/database/backend/server-backend.mjs:1)
    at async Socket.handleEvent (/home/foundry/hexagon/server/resources/app/dist/server/sockets.mjs:1)
_handleError @ foundry.js:1246
(anonymous) @ foundry.js:1230
value @ socket.js:305
value @ socket.js:228
r.emit @ index.js:145
value @ typed-events.js:59
value @ manager.js:214
r.emit @ index.js:145
value @ index.js:120
value @ manager.js:206
r.emit @ index.js:145
value @ socket.js:416
r.emit @ index.js:145
value @ transport.js:107
value @ transport.js:100
ws.onmessage @ websocket.js:112
KayelGee commented 3 years ago

I'll elaborate what I meant with the issue title: You have a setup that looks like the following: Base token -some prefab attached -some other prefab attached -a third prefab attached

Then you delete the base token. This seems to delete everything correctly. But after a refresh(F5) you'll see some elements remaining in the scene. You can remove the remnants with the delete missing links macro.

Looking at your error message it looks like foundry fucked something up. It looks like it is trying to delete something which is already deleted. Not sure if the message is actually coming from MLT. When you try to delete something that doesn't exist the message looks like this:

collection.mjs:106 Uncaught (in promise) Error: The key test does not exist in the EmbeddedCollection Collection
[No packages detected]
    at Map.get (collection.mjs:106)
    at ClientDatabaseBackend._preDeleteDocumentArray (foundry.js:9051)
    at ClientDatabaseBackend._deleteEmbeddedDocuments (foundry.js:9027)
    at ClientDatabaseBackend.delete (backend.mjs:214)
    at async Function.deleteDocuments (document.mjs:402)

So whatever this id is referring to actually exists in your scene but when the database is trying to delete it in the backend it doesn't actually exist.

If the message pops up after every scene change you could go in your browser console then in the sources tab there you should find 'scripts/foundry.js'. Search for "_deleteEmbeddedDocuments" it should only find one occurence. Add a breakpoint at the start of the function, then switch the scene. Now the code should be paused when the deleteembeddeddocuments is actually called. You should be able to see what's inside "documentClass" and "parent" by hovering over them or typing them in your console. "parent" should be the scene and when you look in "parent.data.name" it should tell you the scene name. "documentClass" will be something like "TokenDocument". That way you can at least figure out what's trying to delete what and maybe get a clue at what the cause is. You should also see the call stack which might have some module call in there which would be the initiator.

KayelGee commented 3 years ago

Issue that the title is refering to is fixed in the next update