Skip to content

Migration fails with Foundry API 12 #166

@bneumann

Description

@bneumann

Environment Details

  • Foundry Core Version: 12.331
  • System & Version: Alien RPG 3.2.1
  • OS & Browser: Windows & Firefox
  • Hosting:
    Self Hosted

Describe the bug
Installation of the module and initial usage were fine. Until I restarted my Foundry to set some user rights. After that the module crashes with this error in the console:

Uncaught (in promise) TypeError: (intermediate value)().modules.get(...).data is undefined
[Detected 2 packages: gm-screen(3.0.1), lib-wrapper(1.13.2.0)]
    _gmScreenMigrate migration.js:15
    <anonymous> foundryvtt-gmScreen.js:81
    #call foundry.js:632
    callAll foundry.js:589
    setupGame foundry.js:9098
    _initializeGameView foundry.js:10432
    _initializeView foundry.js:10408
    initialize foundry.js:8995
    initialize#0 libWrapper-wrapper.js:188
    <anonymous> foundry.js:95974
    async* foundry.js:95954

To Reproduce

  1. Install module
  2. Do some editing, whatever
  3. Restart Foundry

Expected behavior
That the module launches

Additional Information
The API 12 documentation does not mention the field .data anymore. But it seems to have the version - which the migration code tries to get - in a top level field now: https://foundryvtt.com/api/classes/foundry.packages.BaseModule.html#defineSchema
So maybe it would suffice to change migration.ts line 27:

if (isNewerVersion(getGame().modules.get(MODULE_ID)?.data.version ?? '0', NEEDS_MIGRATION_VERSION)) return;

to

if (isNewerVersion(getGame().modules.get(MODULE_ID)?.version ?? '0', NEEDS_MIGRATION_VERSION)) return;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions