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

The Settings Application is unable to handle manual wrappers when package ID auto-detection fails. #56

Closed
Varriount opened this issue Oct 10, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Varriount
Copy link

This is a bug in libWrapper, as it prevents libWrapper's "Settings" menu from appearing.

Describe the bug
If a package attempts to wrap a (previously libWrap'd) function without using libWrapper, libWrapper will attempt to automatically wrap the function anyway, assigning it the package ID of «unknown». While this kind of function is registered, attempting to open libWrapper's settings fails. The settings logic throws the following stack trace:

22:46:54.990 Uncaught (in promise) TypeError: can't assign to property "message" on "libWrapper: Invalid package ID '\xABunknown\xBB'": not an object
[Detected 2 packages: settings-extender, lib-wrapper]
    render foundry.js:2012
    promise callback*render foundry.js:2011
    _onClickSubmenu foundry.js:31552
    jQuery 9
    activateListeners foundry.js:31536
    activateListeners settings-extender.js:404
    _render foundry.js:2077
    call_wrapped libWrapper-wrapper.js:467
    <anonymous> listeners.js:111
    _render#0 libWrapper-wrapper.js:162
    _render foundry.js:2736
    render foundry.js:2011
    _onSettingsButton foundry.js:34974
    jQuery 2
        dispatch
        handle

(\xAA and \xAB are the double-arrow marks)

To Reproduce
Steps to reproduce the behavior:

  1. Install libWrapper.
  2. Correctly wrap a function with libWrapper.
  3. Incorrectly wrap the same function.
  4. Attempt to open libWrapper's settings.

Expected behavior
libWrapper's settings application opens.

Screenshots
If applicable, add screenshots to help explain your problem.

Technical Details (please complete the following information):

  • LibWrapper Version: 1.10.7.0
  • FoundryVTT Version: 0.8.9
  • Browser & Version: Firefox 93
@Varriount Varriount added the bug Something isn't working label Oct 10, 2021
@Varriount Varriount changed the title [BUG] libWrapper's settings application is unable to handle "improper" wrappers. Oct 10, 2021
@Varriount Varriount changed the title libWrapper's settings application is unable to handle "improper" wrappers. The Settings Application is Unable to Handle "improper" Wrappers. Oct 10, 2021
ruipin added a commit that referenced this issue Oct 10, 2021
@ruipin
Copy link
Owner

ruipin commented Oct 10, 2021

Thanks for the report! I have pushed a fix in version 1.10.8.0.

This issue was actually more in depth than the report. There were 3 bugs here:

  1. In certain situations, the error message of libWrapper.register would not rely on the package ID provided by the caller when auto-detection failed,
  2. The handling of "unknown" packages (i.e. those that fail auto-detection) was broken in the refactoring done for v10.
  3. Foundry VTT 0.8.x does not like it when exceptions are thrown as a string, rather than as an error object (which is why the stack trace above is inside foundry.js).

Most users/devs wouldn't have noticed this, since in most cases the package ID would have auto-detected correctly and thus the issue wouldn't trigger. For the issue to trigger, it was necessary for the ID auto-detection to fail, which (except for very particular exceptions) should only happen when wrapping from the JS console.

v1.10.8.0 fixes all of these, and does some other code refactoring to improve maintainability and try and avoid similar issues in the future.

With these fixes, the settings dialog now opens as expected, even when doing non-libWrapper wrapping.

I'm closing this now, but feel free to re-open if you notice any remaining issues.

@ruipin ruipin closed this as completed Oct 10, 2021
@ruipin ruipin changed the title The Settings Application is Unable to Handle "improper" Wrappers. The Settings Application is unable to handle manual wrappers when package ID auto-detection fails. Oct 10, 2021
@ruipin ruipin self-assigned this Oct 10, 2021
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

2 participants