dotnet/orleans · warning · Error

/api/load failed with ${response.status}

Error message

/api/load failed with ${response.status}

What it means

A browser-side Error thrown by saveSettings() in the DurableJobsJournaling web frontend when the PUT /api/load request to save load-test settings returns a non-2xx status. Unlike the generic post() helper, this path issues a PUT with a JSON body and checks response.ok before applying the returned settings and refreshing. The message is hardcoded to '/api/load'.

Source

Thrown at playground/DurableJobsJournaling/DurableJobsJournaling.Web/wwwroot/index.html:117

        options.body = JSON.stringify(body);
      }

      const response = await fetch(url, options);
      if (!response.ok) {
        throw new Error(`${url} failed with ${response.status}`);
      }

      await refresh();
    }

    async function saveSettings() {
      const response = await fetch('/api/load', {
        method: 'PUT',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify(settings())
      });
      if (!response.ok) {
        throw new Error(`/api/load failed with ${response.status}`);
      }

      applySettings(await response.json());
      await refresh();
    }

    async function startLoad() {
      await post('/api/load/start', settings());
    }

    function settings() {
      return {
        targetConcurrency: Number(concurrency.value),
        targetStartsPerSecond: Number(throughput.value),
        stageDelayMilliseconds: 0,
        stageJitterMilliseconds: 0,
        failureRate: 0,
        dueTimeMode: 'Immediate',

View on GitHub (pinned to fca799fa70)

Solutions

  1. Read the status code in the message: 400 => invalid settings payload, 404 => route missing, 5xx => server fault.
  2. Validate the settings object client-side (ranges, required fields) before sending the PUT.
  3. Check server logs for model-validation or controller exceptions on /api/load.

Example fix

// before
if (!response.ok) {
  throw new Error(`/api/load failed with ${response.status}`);
}

// after (capture server validation detail)
if (!response.ok) {
  const detail = await response.text().catch(() => "<no body>");
  throw new Error(`/api/load failed with ${response.status}: ${detail}`);
}
Defensive patterns

Strategy: validation

Validate before calling

function validateSettings(s) {
  if (typeof s.rate !== 'number' || s.rate < 0) throw new Error('rate must be >= 0');
  // ...other fields
  return s;
}
// call before fetch('/api/load', ...)

Type guard

function isSettings(o) {
  return o && typeof o === 'object'
    && typeof o.rate === 'number' && o.rate >= 0;
}

Try / catch

async function saveSettings() {
  try {
    const response = await fetch('/api/load', { method:'PUT', headers:{'content-type':'application/json'}, body: JSON.stringify(settings()) });
    if (!response.ok) throw new Error(`/api/load failed: ${response.status}`);
    applySettings(await response.json());
    await refresh();
  } catch (err) {
    showError('Settings not saved: ' + err.message);
  }
}

Prevention

When it happens

Trigger: The user changes settings in the UI and the action triggers saveSettings(); the server rejects the PUT — e.g., the settings JSON fails server validation, the load controller is missing, or the backend is down.

Common situations: Invalid settings values (out-of-range rates, negative counts), a controller/model-validation failure on the server, or backend unavailability. The error status in the message distinguishes them.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/4bde0436d616bcc1. Report an issue: GitHub.