Build fails on Cloudflare Pages

One of my sites fails when building on Pages. It receives a 502 on Flickr urls during the build, causing the failure.

2024-02-28T22:43:23.402939Z	Cloning repository...
2024-02-28T22:43:24.689159Z	From <repo>
2024-02-28T22:43:24.690041Z	 * branch            dc0f694d9a4142a0c85e40f298a624eeffe52721 -> FETCH_HEAD
2024-02-28T22:43:24.6902Z	
2024-02-28T22:43:24.772787Z	HEAD is now at dc0f694 another one
2024-02-28T22:43:24.773323Z	
2024-02-28T22:43:24.873504Z	
2024-02-28T22:43:24.874043Z	Using v2 root directory strategy
2024-02-28T22:43:24.902155Z	Success: Finished cloning repository files
2024-02-28T22:43:25.801208Z	Found a .tool-versions file in user-specified root directory. Installing dependencies.
2024-02-28T22:43:26.47136Z	bun 1.0.1 is already installed
2024-02-28T22:43:26.591454Z	dart-sass-embedded 1.62.1 is already installed
2024-02-28T22:43:26.710446Z	golang 1.21.0 is already installed
2024-02-28T22:43:26.831048Z	hugo extended_0.118.2 is already installed
2024-02-28T22:43:26.930806Z	nodejs 20.5.1 is already installed
2024-02-28T22:43:27.046396Z	python 3.11.5 is already installed
2024-02-28T22:43:27.073165Z	python 2.7.18 is already installed
2024-02-28T22:43:27.187869Z	ruby 3.2.2 is already installed
2024-02-28T22:43:27.201964Z	Detected the following tools from environment: [email protected], [email protected]
2024-02-28T22:43:27.202227Z	Installing nodejs 20.5.1
2024-02-28T22:43:27.274052Z	nodejs 20.5.1 is already installed
2024-02-28T22:43:27.807995Z	Installing project dependencies: npm clean-install --progress=false
2024-02-28T22:43:34.473186Z	
2024-02-28T22:43:34.47348Z	added 419 packages, and audited 420 packages in 6s
2024-02-28T22:43:34.473681Z	
2024-02-28T22:43:34.47384Z	124 packages are looking for funding
2024-02-28T22:43:34.474049Z	  run `npm fund` for details
2024-02-28T22:43:34.476615Z	
2024-02-28T22:43:34.476977Z	6 high severity vulnerabilities
2024-02-28T22:43:34.477117Z	
2024-02-28T22:43:34.477379Z	To address all issues (including breaking changes), run:
2024-02-28T22:43:34.477535Z	  npm audit fix --force
2024-02-28T22:43:34.478082Z	
2024-02-28T22:43:34.478274Z	Run `npm audit` for details.
2024-02-28T22:43:34.492958Z	Executing user command: npm run build
2024-02-28T22:43:35.299213Z	
2024-02-28T22:43:35.299797Z	> build
2024-02-28T22:43:35.300017Z	> rm -rf _site && ELEVENTY_ENV=production npx @11ty/eleventy && npx tailwindcss -i ./assets/tailwind.css -o ./_site/styles.css --minify
2024-02-28T22:43:35.300204Z	
2024-02-28T22:43:36.683011Z	Getting https://webmention.io/...
2024-02-28T22:44:04.806154Z	[11ty] Problem writing Eleventy templates: (more in DEBUG output)
2024-02-28T22:44:04.80653Z	[11ty] 1. Having trouble rendering njk template ./pages/blog.njk (via TemplateContentRenderError)
2024-02-28T22:44:04.806712Z	[11ty] 2. (./pages/blog.njk)
2024-02-28T22:44:04.806852Z	[11ty]   EleventyShortcodeError: Error with Nunjucks shortcode `image` (via Template render error)
2024-02-28T22:44:04.807048Z	[11ty] 3. Bad response for https://live.staticflickr.com/7005/6757151749_304b744910_5k.jpg (502): Bad Gateway (via Template render error)
2024-02-28T22:44:04.807191Z	[11ty] 
2024-02-28T22:44:04.80735Z	[11ty] Original error stack trace: Error: Bad response for https://live.staticflickr.com/7005/6757151749_304b744910_5k.jpg (502): Bad Gateway
2024-02-28T22:44:04.807497Z	[11ty]     at RemoteAssetCache.fetch (/opt/buildhome/repo/node_modules/@11ty/eleventy-fetch/src/RemoteAssetCache.js:76:11)
2024-02-28T22:44:04.807655Z	[11ty]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-02-28T22:44:04.807796Z	[11ty]     at async run (/opt/buildhome/repo/node_modules/p-queue/dist/index.js:163:29)
2024-02-28T22:44:04.808124Z	[11ty] Copied 2 files / Wrote 0 files in 28.14 seconds (v3.0.0-alpha.5)
2024-02-28T22:44:04.85497Z	Failed: Error while executing user command. Exited with error code: 1
2024-02-28T22:44:04.864719Z	Failed: build command exited with code: 1
2024-02-28T22:44:05.842848Z	Failed: error occurred while running build command

Is there an issue specifically with Flickr by chance?

Yeah, that seems like the error trying to get an image from flickr is causing the built to fail.

Agreed. I was asking Flickr about it too, and was putting together a smaller repro of the issue when I retried my latest failed build on a whim and it completed successfully.

Unfortunately that doesn’t give me a ton of confidence in the build process here so I’ll have to watch it for awhile. :-/

I think the build process on Cloudflare is fine, just Flickr responding with the 502 errors causing the issues.