Skip to content

Conversation

danpeen
Copy link
Contributor

@danpeen danpeen commented Aug 27, 2025

feat(retry-plugin): add getRetryPath in retry plugin to support uses to customize retry path.

Description

Allow rewriting request URLs during retries to switch fallback domains, bust caches, or route traffic.

New Options:

  • Fetch retry: fetch.getRetryPath?: (url: string) => string
  • Script retry: script.getRetryPath?: (url: string) => string

Behavior:

Before each retry, the plugin calls getRetryPath(originalUrl) to compute the retry URL. If not provided, the original URL is used.

Example

 RetryPlugin({
    fetch: {
      retryTimes: 3,
      getRetryPath: (url) => `${url}?retry_ts=${Date.now()}`,
    },
    script: {
      retryTimes: 3,
      retryDelay: 1000,
      getRetryPath: (url) => url.replace('cdn.a.com', 'cdn.b.com'),
    },
  });

Notes

  • Keep getRetryPath pure and fast; avoid throwing.
  • Ensure returned URLs are valid and reachable; add version/hash if needed to avoid cache collisions.

Related Issue

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Copy link

changeset-bot bot commented Aug 27, 2025

🦋 Changeset detected

Latest commit: adc6f1d

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

This PR includes changesets to release 36 packages
Name Type
@module-federation/retry-plugin Patch
@module-federation/runtime-core Patch
@module-federation/runtime Patch
@module-federation/bridge-react Patch
@module-federation/devtools Patch
@module-federation/data-prefetch Patch
@module-federation/dts-plugin Patch
@module-federation/metro Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/runtime-tools Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-vue3 Patch
@module-federation/enhanced Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspack Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
remote5 Patch
website-new Patch
@module-federation/sdk Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/error-codes Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch

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

Copy link

netlify bot commented Aug 27, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit adc6f1d
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/68b58600353d8e00085934b6
😎 Deploy Preview https://deploy-preview-4023--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@danpeen danpeen changed the title Feat/support get retry path in retry plugin WIP: add getRetryPath in retry plugin to support users to customize retry path Aug 27, 2025
@danpeen danpeen changed the title WIP: add getRetryPath in retry plugin to support users to customize retry path feat(retry-plugin): add getRetryPath in retry plugin to support users to customize retry path Sep 1, 2025
@2heal1
Copy link
Member

2heal1 commented Sep 1, 2025

Can you provide more info for getRetryPath ? Like the retried url map .

This is very useful to choose suitable url if users have multiple backup urls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants