Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incorrect error message when calling the libWrapper API before the libWrapper.Ready hook #72

Closed
ruipin opened this issue Sep 11, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ruipin
Copy link
Owner

ruipin commented Sep 11, 2022

Describe the bug
When trying to register a wrapper before the libWrapper.Ready hook, if this happens before game.modules is available, libWrapper will try to construct an error message and fail with an error message like:

[Detected 2 packages: lib-wrapper, XYZ]
    at PackageInfo.get exists [as exists] (libWrapper-package_info.js:328)
    at de (libWrapper-api.js:273)
    at Function.🎁register [as register] (libWrapper-api.js:471)
    at XYZ.js:5

To Reproduce
Steps to reproduce the behavior:

  1. Write a module which calls libWrapper.register before the libWrapper.Ready hook fires.
  2. Enter a world and enable the module.
  3. Refresh.
  4. See the error in the JS console.

Expected behavior
libWrapper should give the error Not allowed to register wrappers before the 'libWrapper.Ready' hook fires instead.

Technical Details (please complete the following information):

  • LibWrapper Version: 1.12.8.0 (and older)
  • FoundryVTT Version: Any
  • Browser & Version: Any

Additional context
This seems to be caused by api.js:475, which throws a LibWrapperPackageError exception when libWrapper isn't ready yet, which will trigger a PackageInfo::exists call during the error message construction.

This PackageInfo::exists method does not correctly handle the case where game.modules is undefined.

@ruipin ruipin added the bug Something isn't working label Sep 11, 2022
@ruipin ruipin changed the title [BUG] [BUG] Incorrect error message when calling libWrapper.register before the libWrapper.Ready hook Sep 11, 2022
@ruipin ruipin self-assigned this Sep 11, 2022
@ruipin
Copy link
Owner Author

ruipin commented Sep 11, 2022

Fixed by v1.12.9.0. Closing.

@ruipin ruipin closed this as completed Sep 11, 2022
@ruipin ruipin changed the title [BUG] Incorrect error message when calling libWrapper.register before the libWrapper.Ready hook [BUG] Incorrect error message when calling the libWrapper API before the libWrapper.Ready hook Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant