cppreference.com embeds hang and report CORS errors when gsnapshot compiles time out

Author: mattgodbolt-moltyCreated Sep 25, 2026Updated Sep 25, 2026
Labelsbug

cppreference.com now embeds CE to run its examples. Some of those runs hang on "Building and running..." and the browser console reports a CORS error:

Access to XMLHttpRequest at 'https://godbolt.org/api/compiler/gsnapshot/compile' from origin 'https://cppreference.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Reported on the define_aggregate example (https://cppreference.com/cpp/meta/define_aggregate), GCC trunk (C++26).

What is actually happening

The requests are not being refused. The preflight and the POST from Origin: https://cppreference.com both return 200 with Access-Control-Allow-Origin: *, and the define_aggregate example compiles and runs correctly (about 10s cold). The CORS message is a symptom: when a request times out, the response comes from CloudFront rather than CE, carries no CORS headers, and the browser reports that as a CORS block.

CloudFront logs for requests with a cppreference referer, 2026-09-23 to 09-25:

outcome POSTs time taken
200 1,550 p50 0.8s
504 (CloudFront origin read timeout) 24 all at 60s
000 (viewer gave up) 109 p50 20s
502 3 21 to 41s

128 of the 136 failures are gsnapshot. Today about 10% of cppreference's gsnapshot runs failed, against 2.1% for gsnapshot overall and 0.2% for g162. gsnapshot's own successful compiles have a long tail (p90 8s, p99 38s), and C++26 examples pulling in <meta> and <print> sit at the slow end of it; the 60s CloudFront and ALB timeouts cut off the rest. The cluster of viewer aborts around 20s may be a timeout on the embedding side.

Possible fixes

  • Make timeouts and edge errors carry CORS headers, so embedders see a timeout instead of a misleading CORS error. A CloudFront response headers policy may cover CloudFront-generated error responses; needs testing, since CE sets the header itself today (infra).
  • Find out why gsnapshot compiles of these headers take tens of seconds (queueing on busy nodes, cold cache on a nightly compiler, or the compile itself), and whether the pinned g162 would serve cppreference's C++26 examples as well.
  • Ask cppreference what client timeout they use, and whether they could show a retry rather than hanging.

Generated with Claude Code

https://claude.ai/code/session_019UuPJbXuMH8A4DCDNoiBiv

Source: compiler-explorer/compiler-explorer