apostrophecms / apostrophe-workflow

Provides approval-based workflow and localization capabilities for projects that need them. An optional component of the Apostrophe CMS.
MIT License
36 stars 20 forks source link

Assembly Bug with v2.39.2 #340

Open egonzalezg9 opened 3 years ago

egonzalezg9 commented 3 years ago

Version 2.39.2 of workflow causes assembly to crash when creating new sites that utilize apostrophe-headless. All you need to do to reproduce is use version 2.39.2 and have a theme with the following apostrophe-headless configurations:

    'apostrophe-headless': {
      cors: {
        origin: 'http://localhost:4000'
      }
    },
abea commented 3 years ago

I found this as well. The problem is here: https://github.com/apostrophecms/apostrophe-workflow/blob/c4c3e2d72f799a78e48415259d985555ea8a9e22/lib/modules/apostrophe-workflow-pages/index.js#L35-L40

The self.modulesReady function does not return anything and doesn't run the callback so when Headless also improves the pages module and uses a self.modulesReady method it can't run.

abea commented 3 years ago

I think it should be changed to something like this:

    const superModulesReady = self.modulesReady;
    self.modulesReady = function(callback) {
      return superModulesReady(function(err) {
        if (err) {
          console.error(err);
        }

        self.autoCommitPageMoves = self.apos.modules['apostrophe-workflow']
          .options.autoCommitPageMoves || false;
        return callback(null);
      });

    };

I haven't tested that much yet other than confirming a broken site can run with it.