Application Modules

Streaming Graph Rebuilds

Stream graph rebuild progress logs to your UI in real time using Server-Sent Events via /api/build/stream.

Streaming Graph Rebuilds

If your application triggers a graph rebuild (for example, by modifying an asset via the API), you can stream the rebuild progress logs directly to your UI using Server-Sent Events (SSE) via the /api/build/stream endpoint.

The stream emits log messages as they occur and sends a final BUILD_COMPLETE message when the process finishes.

function showBuildProgress() {
  const eventSource = new EventSource('/api/build/stream');

  eventSource.onmessage = function(event) {
    const msg = event.data;
    if (msg === 'BUILD_COMPLETE') {
      console.log('Graph rebuild complete!');
      eventSource.close();
      // Refresh application data here
    } else {
      console.log('Build log:', msg);
    }
  };

  eventSource.onerror = function() {
    console.error('Connection to build stream lost.');
    eventSource.close();
  };
}