Skip to content

Bluebird config not allowed when promises already in use #385

@stsje

Description

@stsje

I'm submitting a bug report

  • Library Version:
    0.21.0
  • Browser:
    Firefox, Edge, IE 11

Current behavior:
An error is thrown if you enable bluebird's cancellation option: cannot enable cancellation after promises are in use. The error doesn't occur in Chrome.

A newly created CLI project has the bluebird configuration in main.js.

Example configuration in main.js that fails at startup:

import environment from './environment';

//Configure Bluebird Promises.
//Note: You may want to use environment-specific configuration.
Promise.config({
  warnings: {
    wForgottenReturn: false
  },
  cancellation: true
});

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature('resources');

  if (environment.debug) {
    aurelia.use.developmentLogging();
  }

  aurelia.start().then(() => aurelia.setRoot());
}

Expected/desired behavior:
A newly setup project should allow any bluebird configuration options without failing.

The aurelia-bootstrapper module seems to be using promises in any other browser than Chrome before main.js is loaded.

One option is to change the bootstrapper, so it doesn't use promises. This will allow us to use the current clean setup, that is easy for people to understand.

Another option, which is our current fix, is to configure bluebird in index.html. Our index file is then changed to:

<!--<script src="dist\vendor-bundle.js" data-main="aurelia-bootstrapper"></script>-->
<script src="dist\vendor-bundle.js"></script>
<script>
  requirejs.config({
    skipDataMain: true
  });

  // Configure Bluebird Promises.
  Promise.config({
    warnings: {
      wForgottenReturn: false
    },
    cancellation: true
  });

  require(['aurelia-bootstrapper']);
</script>

Note that the requirejs config isn't actually needed, but it still might be a good idea to tell it not to look for data-main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions