Skip to content

Error: the options.bootstrapFunction must return a promise #574

@kfrederix

Description

@kfrederix

Hello, I am getting this error since we upgraded to Angular 21:

Uncaught Error: application 'smc-mf-content' died in status SKIP_BECAUSE_BROKEN: single-spa-angular: the options.bootstrapFunction must return a promise, but instead returned a 'object' that is not a Promise
    at mount (single-spa-community-angular.mjs:206:15)
    at lifecycle.helpers.js:28:29

It seems to come from this line:

if (!(bootstrapPromise instanceof Promise)) {

We did not have it before, so I am thinking that probably something internal in Angular changed that impacts the bundling. We use the Angular application builder (esbuild). Or maybe it's because we "externalize" single-spa via our importmap? (but we were doing that already before...)

In any case, I took a look at what single-spa itself is doing internally and I believe that implementation is a bit more robust:

export function smellsLikeAPromise(promise) {
  return (
    promise &&
    typeof promise.then === "function" &&
    typeof promise.catch === "function"
  );
}

I have tried patching single-spa-angular with this smellsLikeAPromise approach (instead of instanceof Promise) and that works like a charm for us.

Would you accept a PR for this smellsLikeAPromise approach on this repo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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