earlSt1 / vtt-compendium-folders

Collapsable folders in the compendium directory and folder structures inside compendiums for FoundryVTT
21 stars 18 forks source link

JS Error Closing Certain Items #141

Closed Jeznar closed 2 years ago

Jeznar commented 2 years ago

Compendium Folders

When I have Compendium Folders active and I close certain items' sheet that was imported from a compendium folder (e.g. Dagger, JSON of that item, disguised as a .txt file, attached) a big fat error message pops in the log.

fvtt-Item-dagger.json.txt

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'folders')
[Detected 2 packages: compendium-folders, system:dnd5e]
    at Function.importFolderData (fic-folders.js:1509)
    at fic-folders.js:460
    at Function._call (foundry.js:294)
    at Function.callAll (foundry.js:253)
    at TokenDocument5e._onUpdateTokenActor (foundry.js:19244)
    at TokenDocument5e._onUpdate (foundry.js:19140)
    at ClientDatabaseBackend.callback (foundry.js:10300)
    at foundry.js:10283
    at Array.map (<anonymous>)
    at ClientDatabaseBackend._handleUpdateEmbeddedDocuments (foundry.js:10283)
    at ClientDatabaseBackend._updateEmbeddedDocuments (foundry.js:10163)
    at async Function.updateDocuments (document.mjs:373)
    at async TokenDocument5e.update (document.mjs:456)
    at async TokenDocument5e.updateActorEmbeddedDocuments (foundry.js:18996)
    at async Function.updateDocuments (document.mjs:373)
    at async Item5e.update (document.mjs:456)
    at async ItemSheet5e._onSubmit (foundry.js:3853)
    at async ItemSheet5e._onSubmit (sheet.js:543)
    at async ItemSheet5e.submit (foundry.js:4136)
    at async ItemSheet5e.close (foundry.js:4108)
    at async ItemSheet5e.close (foundry.js:4220)

Sometimes, when I make additions to the dagger's description, both the above error and the following pop into the log:

contexts.ts:164 Uncaught TypeError: Cannot read properties of undefined (reading 'top')
[Detected 1 package: quick-insert]
    at new TinyMCEContext (contexts.ts:164)
    at _x.<anonymous> (tinyMCEPlugin.ts:9)
    at rx.fire (tinymce.min.js:9)
    at _x.fire (tinymce.min.js:9)
    at ax (tinymce.min.js:9)
    at Object.e (tinymce.min.js:9)
    at ui.executeHandlers (tinymce.min.js:9)
    at HTMLBodyElement.o (tinymce.min.js:9)

Changes made appear to be entered correctly. I've not seen any other impact to the game from this, other than polluting the log with error messages.

Isolated Testing

When I turn off all modules, except Compendium Folders, a warning appears about lib-wrapper being missing and the troublesome items generate a smaller, but similar error message.

Activating lib-wrapper generates, what appears to be the same error message as when all modules were active for my trouble making Dagger:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'folders')
[Detected 2 packages: compendium-folders, system:dnd5e]
    at Function.importFolderData (fic-folders.js:1509)
    at fic-folders.js:460
    at Function._call (foundry.js:294)
    at Function.callAll (foundry.js:253)
    at TokenDocument5e._onUpdateTokenActor (foundry.js:19244)
    at TokenDocument5e._onUpdate (foundry.js:19140)
    at ClientDatabaseBackend.callback (foundry.js:10300)
    at foundry.js:10283
    at Array.map (<anonymous>)
    at ClientDatabaseBackend._handleUpdateEmbeddedDocuments (foundry.js:10283)
    at ClientDatabaseBackend._updateEmbeddedDocuments (foundry.js:10163)
    at async Function.updateDocuments (document.mjs:373)
    at async TokenDocument5e.update (document.mjs:456)
    at async TokenDocument5e.updateActorEmbeddedDocuments (foundry.js:18996)
    at async Function.updateDocuments (document.mjs:373)
    at async Item5e.update (document.mjs:456)
    at async ItemSheet5e._onSubmit (foundry.js:3853)
    at async ItemSheet5e._onSubmit (sheet.js:543)
    at async ItemSheet5e.submit (foundry.js:4136)
    at async ItemSheet5e.close (foundry.js:4108)
    at async ItemSheet5e.close (foundry.js:4220)

Uninformed Speculation

Perhaps the problem is something that is polluting the data structure of existing items, perhaps those that were pulled from a compendium in (or not in a folder). The problem appears to have no impact other than tossing an error message, but that is worrisome and justifies my disabling the module (sadly, as I like what it does).

earlSt1 commented 2 years ago

Hi, sorry for the wait, looking into this now.

Can you run the following macro in your world and let me know the output:

console.log('importing setting: '+game.settings.get('compendium-folders','importing'))
Jeznar commented 2 years ago

Sorry for the delay, I am on the road. Access to my game is spotty. I did the run:

console.log('importing setting: '+game.settings.get('compendium-folders','importing'))
importing setting: false
undefined

I also confirmed that I still get the error. It seems to be only (maybe) from items that were compendium imports. I'm not understanding the trailing undefined, but it popped (in grey text), so I included it.

earlSt1 commented 2 years ago

Could you try again with the module setting Auto create folders for import disabled? I'm not sure why i added this option as it seems a bit janky haha :smile:

Jeznar commented 2 years ago

Sorry again for the delay. I arrived at an actual hotel (was on a ship) and tried it with Auto create folders for import disabled...bang! Success.

That works for me. I'm not sure what the option that was enabled was trying to do for me, but certainly seems happier off than on.

earlSt1 commented 2 years ago

Great, I've effectively disabled that option in v2.4.4. I introduced it ages ago to allow folders to be created when you dragged an item from a compendium into the world, but it's too clunky and annoying, and it broke things like this.

Will close this issue for now :smile:

Jeznar commented 2 years ago

Thank you!

-Joe Barrett Sent from my iPhone (sorry got typos, keyboard is mighty small)

On May 29, 2022, at 11:12 AM, Craig Earl @.***> wrote:

 Closed #141 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.