Skip to content

fix: use setTimeout for cross-compatibility #375

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

Merged

Conversation

ghiscoding
Copy link
Contributor

@ghiscoding ghiscoding commented Jun 28, 2025

  • queueMicrotask is apparently not supported in Salesforce (which is weird), so for better cross-compatibility using setTimeout works in all environments (including Salesforce)
  • another option might be to use a function to check if it's available or fallback to setTimeout when not available, but I think it's overkill for this project (I did implement this in my own project though, let me know if you would rather have that approach as seen below)
export function queueMicrotaskOrSetTimeout(callback: () => void): void {
  try {
    queueMicrotask(callback);
  } catch {
    setTimeout(callback, 0);
  }
}

@uvarov-frontend uvarov-frontend merged commit 72a36b1 into uvarov-frontend:main Jul 16, 2025
2 checks 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.

2 participants