Skip to content

feat(core): adds flag to allow analytics.ready() to run even if plugin fails on ready #1282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmachado-studocu
Copy link

@rmachado-studocu rmachado-studocu commented Apr 26, 2025

What does this PR do

  • Refactors analytics.ready() to use Promise.allSettled() and extracting only the successfully readied plugins.
  • Adds support for onPluginReadyError - error handler for plugins that error in the ready stage

If onPluginReadyError is provided, this function will be used as .catch() of the plugin.ready promises.

Closes #1281

  • I've included a changeset (psst. run yarn changeset. Read about changesets here).

Copy link

changeset-bot bot commented Apr 26, 2025

🦋 Changeset detected

Latest commit: 6b0d9fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rmachado-studocu rmachado-studocu force-pushed the run-ready-even-on-plugin-ready-failure branch 2 times, most recently from 9ce37d2 to 47bda2b Compare April 26, 2025 17:02
@rmachado-studocu
Copy link
Author

An alternative to this implementation could be to instead implement a new function for this. Example:

readySettled: (cb, onPluginReadyError) => {
	// here would be the Promise.allSettled()
}

@rmachado-studocu
Copy link
Author

Hi @silesky and @MichaelGHSeg (sorry for the tags),

Is this something you'd see being implemented or no? Just to understand how to proceed with this feature.

return res
})
}

return Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing an allSettled and then an .all here like duplicate work -- Can we refactor to just use allSettled?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* Adds `onPluginReadyError` which is passed as a `catch` of each
plugin's `ready()` call.
@rmachado-studocu rmachado-studocu force-pushed the run-ready-even-on-plugin-ready-failure branch from 47bda2b to 6b0d9fe Compare May 1, 2025 11:31
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.

When an integration/plugin fails on ready it prevents analytics.ready()'s execution
2 participants