Skip to content

fix: accept thenable bootstrapFunction return values (#574)#575

Merged
arturovt merged 2 commits into
single-spa:masterfrom
kfrederix:fix/bootstrap-promise-cross-realm
Jun 13, 2026
Merged

fix: accept thenable bootstrapFunction return values (#574)#575
arturovt merged 2 commits into
single-spa:masterfrom
kfrederix:fix/bootstrap-promise-cross-realm

Conversation

@kfrederix

@kfrederix kfrederix commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace instanceof Promise with duck-typed promise detection when validating bootstrapFunction return values
  • Add smellsLikeAPromise helper aligned with single-spa's own promise detection
  • Fixes Angular 21 + esbuild/importmap setups where bootstrap promises come from a different Promise constructor

Fixes #574

Test plan

  • Added unit tests for smellsLikeAPromise (native promises, foreign thenables, invalid values)
  • yarn test
  • Verify affected microfrontend mounts successfully after upgrade

@arturovt please let me know if you have any concerns about this?

Use duck-typed promise detection instead of instanceof Promise so
bootstrapFunction works when Angular bundles return a Promise from a
different realm or module copy.

Co-authored-by: Cursor <[email protected]>
Comment thread libs/single-spa-angular/src/single-spa-angular.ts Outdated
Comment thread libs/single-spa-angular/src/single-spa-angular.ts Outdated
@arturovt

Copy link
Copy Markdown
Member

I'll merge this afternoon and publish.

@arturovt arturovt merged commit b984dae into single-spa:master Jun 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: the options.bootstrapFunction must return a promise

2 participants