You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I assume the GM role and call the function without calling socket.executeAsGM it works. When as GM i call the function using the socket.executeAsGM works. However, when i added the socket.executeAsGM, and try to run as player (with another browser open as GM) it doesn't work.
In the GM console i get the error
foundry.js:753 TypeError: Error thrown in hooked function 'onDiceSoNiceRollStart' for hook 'diceSoNiceRollStart'. Cannot read properties of undefined (reading 'system')
[Detected 2 packages: system:swade, dice-so-nice]
at Object.onDiceSoNiceRollStart [as fn] (SwadeIntegrationHooks.ts:80:50)
at #call (foundry.js:730:20)
at Hooks.callAll (foundry.js:687:17)
at Dice3D.showForRoll (Dice3D.js:645:15)
at recursShowForRoll (Dice3D.js:597:22)
at Dice3D.renderRolls (Dice3D.js:606:13)
at Object.fn (main.js:249:17)
at #call (foundry.js:730:20)
at Hooks.callAll (foundry.js:687:17)
at ClientDatabaseBackend.callback (foundry.js:13538:13)
at foundry.js:13510:43
at Array.map (<anonymous>)
at #handleCreateDocuments (foundry.js:13510:33)
I came to write a similar error, Ive found a solution however wondering if there is a more efficient way. I believe its because once referenced objects such as Actors, Tokens, Items etc are passed into socket functions they are passed as values so no longer reference the original object.
I circumvented this by instead of passing the token itself into the socket function I pass the token._id and inside the function run game.actors.get(id) or canvas.tokens.get(id) which will get the original object you wanted to pass by reference. I imagine theres a better way with less function calls, such as global variables but that creates other issues.
With the current socketlib API, only values can be passed around that can be converted to JSON. Trying to pass a token fails, because tokens have circular references, which lead to a stack overflow when trying to convert them to JSON. If you need to send a token you'll need to go the route @OhhLoz described: Pass the token ID and then load the token on the other side using canvas.tokens.get(id).
I'll keep this issue around as a request to automatically to the conversion to an id (and back) in socketlib, so that entities can be passed around transparently.
manuelVo
changed the title
Uncaught (in promise) InternalError: too much recursion
Allow to send entities as parameters
Jun 26, 2023
Hi,
I'm trying to apply an affect as an user to a token player doesn't have control.
in my module file I have the code below
this is the applyDoc function
and I call the function as below
The target is the token entity, and the effectDoc is the effect item.
When I assume the GM role and call the function without calling socket.executeAsGM it works. When as GM i call the function using the socket.executeAsGM works. However, when i added the socket.executeAsGM, and try to run as player (with another browser open as GM) it doesn't work.
In the GM console i get the error
In the player console I get the error:
The text was updated successfully, but these errors were encountered: