Skip to content
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

Added import retries into packager #305

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Added import retries into packager #305

merged 1 commit into from
Jan 9, 2025

Conversation

alshdavid
Copy link
Contributor

@alshdavid alshdavid commented Jan 8, 2025

The previous import retry feature gave the consumer the ability to retry failed requests. This required the consumer to handle the actual retry logic:

for (let i = 0; i < 5; i++) {
  try {
    await import('./foo')
  } catch(err) {
    await new Promise(res => setTimeout(res, 1000))
  }
}

This PR added the retry logic into the JavaScript runtime, enabled with --feature-flag importRetry=true

await import('./foo') // will auto retry on failure

For reporting purposes, it will also emit a custom event on the window to notify when retries were triggered

window.addEventListener('atlaspack:import_retry', ({detail}) => console.log(detail));

@alshdavid alshdavid enabled auto-merge (squash) January 9, 2025 04:57
@alshdavid alshdavid force-pushed the alsh/import-retries branch from cd9ff7c to 18b239d Compare January 9, 2025 05:22
@alshdavid alshdavid merged commit c3c2571 into main Jan 9, 2025
17 checks passed
@alshdavid alshdavid deleted the alsh/import-retries branch January 9, 2025 05:36
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