Maintenance Mode

The SDK detects maintenance mode reactively via 503 responses. Write operations are blocked; reads are still allowed.

Event Handlers

The simplest way to handle maintenance is via constructor callbacks:

1const sdk = new WorkAppsSDK({2  onMaintenanceStart: (status) => {3    // status.message and status.estimatedSeconds may be set4    document.getElementById('maintenance-banner').style.display = 'block';5    document.getElementById('maintenance-message').textContent =6      status.message ?? 'App is being updated.';7  },8  onMaintenanceEnd: () => {9    document.getElementById('maintenance-banner').style.display = 'none';10  },11});

Or attach/remove handlers dynamically with the event API:

1// sdk.on() returns an unsubscribe function — the simplest way to clean up:2const unsubStart = sdk.on('maintenanceStart', (status) => { /* ... */ });3const unsubEnd   = sdk.on('maintenanceEnd', () => { /* ... */ });45// Remove later:6unsubStart();7unsubEnd();89// Alternatively, use sdk.off() with a reference to the original handler:10const handler = (status) => { /* ... */ };11sdk.on('maintenanceStart', handler);12sdk.off('maintenanceStart', handler);

Write Behavior

Write operations (createRecord, updateRecord, deleteRecord, all bulk write methods) throw MaintenanceError immediately if the SDK is already in maintenance state — they do not hit the server:

1try {2  await sdk.createRecord('tasks', data);3} catch (error) {4  if (error instanceof WorkAppsSDK.MaintenanceError) {5    showMessage('App is being updated. Please try again shortly.');6  }7}

Read Behavior

Read operations (listRecords, getRecord, paginateRecords, getSchema, getBootstrap) are allowed during maintenance and may succeed depending on server behavior.

Automatic Recovery

Maintenance mode clears automatically — if any request succeeds after a 503, the SDK exits maintenance mode and fires maintenanceEnd. You do not need to call any method to reset it.

Proactive Detection

The SDK only detects maintenance reactively (when a request returns 503). For proactive detection before a write fails, implement your own status poller:

1const poller = setInterval(async () => {2  const status = await sdk.getStatus();3  if (status.status === 'maintenance') {4    showMaintenanceBanner(status.message);5  } else {6    hideMaintenanceBanner();7  }8}, 15_000);910// Clean up when done:11clearInterval(poller);12sdk.destroy();

getStatus() returns { status: 'ok' | 'maintenance', message?: string, estimatedSeconds?: number }.

getStatus(signal?)

Fetches the current app status without triggering maintenance mode detection. Use this for proactive polling.

1const status = await sdk.getStatus();2// status.status           — 'ok' | 'maintenance'3// status.message          — optional human-readable message4// status.estimatedSeconds — optional estimated downtime in seconds