Skip to content

Unable to use subscriptions.getMigrationErrors() during initialization

Environment

  • Browser and full version: Chrome 105.0.5195.125
  • Extension using this toolkit:
    • test-mv2 (based on 0.6.1)
    • test-mv3 (based on 0.7.0)
  • Commit hash: 0.7.0

Steps to reproduce

  1. Set value of "version" property in manifest.json file to "0.0.2" to avoid #383 (closed).
  2. Add EWE.subscriptions.getMigrationErrors().forEach(console.error) call as part of the extension initialization (e.g. right after EWE.start() has finished).
  3. Generate migration error (taken from #384 (closed)):
    1. Copy "test-mv2" directory and rename it to "test".
    2. Install "test" directory as unpacked extension.
    3. Run await EWE.subscriptions.add("https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt").
    4. Remove "test" directory.
    5. Copy "test-mv3" directory and rename it to "test".
    6. Reload unpacked extension.
  4. Run EWE.subscriptions.getMigrationErrors().

Actual behavior

  • After 3.6) No migration errors are logged during extension initialization.
  • After 4) Migration errors are returned.

Expected behavior

  • After 3.6) Migration errors are logged during extension initialization.
  • After 4) Migration errors are returned.

Further information

When it comes to knowing when it's safe to call EWE.subscriptions.getMigrationErrors(), the API documentation doesn't mention anything and the EWE 0.7.0 release notes only mention "Once the migration happened". In general, there doesn't appear to be a way for consumers to get notified about new migration errors.

Apart from that, since the migration may still be ongoing even after the promise that's returned by EWE.start() resolve, it's unclear whether it's safe to use other APIs (e.g. subscriptions.getDownloadable()) after EWE.start() but before the migration is done. Therefore it may make more sense to run the migration as part of EWE.start() to ensure that the filter storage is in the correct state when its promise resolves.