Unknown error accessing the Forge API
Closed this issue · 7 comments
I'm enjoying the module and the favorites buttons are great but every time I refresh or ctrl+f5 with filepicker improvements active I get these error notifications.
v9.249, 5e 1.5.7, hosted on the forge. Same behavior in firefox and chrome. No errors are apparent in the console. Find the culprit points to filepicker improvements and I see the errors with only filepicker improvements and libwrapper active on a clean world. Disabling filepicker improvements causes the errors to stop popping up. I'm not sure if it's doing anything problematic but any info on what might be causing the error would be appreciated.
.
That is probably a problem with indexing the images for the search with the forge upload. Sadly I do not have a forge account to try this out. I would need access to a game with file browsing privileges to fix this properly.
I'd be happy to send you an invite to my game if it would help. And regardless, thanks for looking at this and for your work on the mod.
With the help of @MrPotatoZed I could look at this error.
First of all: there is no actual problem and everything works as intended.
Detailed explanation:
- Filepicker Improvements needs to looks through all the files to create a list of them
- this can take a lot of time depending on the number of directories and the connection speed to the server
- the forges filepicker extension that adds their custom sources automatically shows this error message whenever a connection is closed unexpectedly
- when you refresh the page while my module is still creating the list your sever such a connection or two and thus trigger the error
- this should not be a problem in any way
First of all: there is no actual problem and everything works as intended.
The module has been known to continuously browse the folder in an infinite loop, doing dozens of browse requests per second for hours on end, until the browser runs out of RAM and starts crashing. I don't think that's what you mean by "everything works as intended". The errors seem to happen when the browser itself becomes unable to handle the amount of requests being sent, or Cloudflare starts to reject API requests as it starts to consider it as DDoS.
As for a need to look through all the files, I'd recommend (other than finding where your infinite loop is), to do something like this :
if (typeof (ForgeVTT) !== "undefined" && ForgeVTT.usingTheForge) {
// Running on the Forge, retrieve the entire assets library of the user using a single Forge API call
const assets = await ForgeAPI.call("assets");
}
Sadly I do not have a forge account to try this out.
Contact us on Discord, or send us an email (https://forge-vtt.com/contact), we do offer free accounts to Foundry system and module developers. We'll just need the email address associated with your Forge account and I can give you the 'developer' role, which bumps you to Story Teller automatically and unlocks the DDB integration as well.
I'd recommend re-opening this issue until it's resolved.
Thanks!
That sounds very good. Reducing the number of calls is great.
I am not sure what to do about the memory problem though. Maybe it makes sense to just stop and notify the user if there are too many images in the library.
I was finally able to look into this. Is there a full documentation of the API somewhere?
I also need the endpoint to call for the bazaar content.
I was finally able to look into this. Is there a full documentation of the API somewhere?
I also need the endpoint to call for the bazaar content.
No documentation for the API unfortunately, as it's always been an internal API, though I expect we'll need to change that as more people are starting to use.
For the Bazaar files, there isn't actually an API to list their content, other than the browse API using "forge-bazaar" source... but you reminded me that we also support another undocumented feature which might actually be much better for you. When you use FilePicker.browse
, you can give it a {recursive: true}
option to get all the files recursively. You can use that to browse the assets library or the Bazaar recursively. For the Bazaar, you can only do it on specific modules (not with ""
as target or "modules"
as target).
For example :
I think that'd be a simpler change from your side since the resulting data is already in a format you're used to, and it would work for both the assets library and the bazaar.