Skip to content

Commit 31484aa

Browse files
ascorbickodiakhq[bot]
andauthoredMar 15, 2024
fix: prewarm entrypoint (#351)
* fix: prewarm entrypoint * chore: remove log * chore: add comment --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 58db060 commit 31484aa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ export const onPostBuild = async (options: NetlifyPluginOptions) => {
5252
await publishStaticDir(new PluginContext(options))
5353
}
5454

55+
export const onSuccess = async () => {
56+
const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter(
57+
// If running locally then the deploy ID is a placeholder value. Filtering for `https://0--` removes it.
58+
(url?: string): url is string => Boolean(url && !url.startsWith('https://0--')),
59+
)
60+
await Promise.allSettled(prewarm.map((url) => fetch(url)))
61+
}
62+
5563
export const onEnd = async (options: NetlifyPluginOptions) => {
5664
await unpublishStaticDir(new PluginContext(options))
5765
}

0 commit comments

Comments
 (0)
Please sign in to comment.