Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlAdler's avatar

Video Session Disruption Due to Inertia "409 Conflict" During Deployment

Hi everyone, I'm running into a tricky issue with our video conferencing application that uses Inertia.js (+ React). The problem occurs specifically after a deployment when users are in active video call, and then they interact the site making a request to the server.

The Issue

When we deploy new code while users are in active call, the following cascade of events happens:

  • The code version changes
  • Any interaction by the user with the site that triggers an AJAX call (Inertia form) triggers a "409 Conflict" response
  • This causes Inertia's JavaScript to perform a full page reload because the code has changed
  • The video call is interrupted because the entire site reloaded
  • This causes all kinds of problems and disruptions to the users and feels super buggy

The 409 functionality that Inertia.js has built-in is awesome and I was very happy when I saw that in the docs, as dealing with stale code can be a real pain, but I didn't think of this case and now I'm seeking your advice.

Has anyone encountered similar issues with Inertia during deployments, especially with video/WebRTC applications? How did you handle it? Thinking about Laracasts... I believe it is built with Inertia.js, what happens if I'm in the middle of watching a video and a deploy happens and then I click the "heart" button? That seems like an Inertia request from a quick look, so how do they handle not refreshing my page while I'm watching a video.

What are some recommended strategies to handle version mismatches more gracefully?

Are there ways to prevent the 409 conflicts from triggering full page reloads, or at least manage them more smoothly, delay them?

Any insights or suggestions would be greatly appreciated. Thanks in advance!

0 likes
1 reply
LaryAI's avatar
Level 58

To address the issue of "409 Conflict" responses causing disruptions during video calls in your Inertia.js application, you can consider several strategies to handle version mismatches more gracefully. Here are some potential solutions:

  1. Graceful Handling of 409 Conflicts:

    • Instead of allowing Inertia to automatically reload the page on a 409 conflict, you can intercept this response and handle it more gracefully. You can use Inertia's event system to listen for the invalid event and implement custom logic to delay the reload or notify the user.
    import { Inertia } from '@inertiajs/inertia';
    
    Inertia.on('invalid', (event) => {
      // Custom logic to handle the 409 conflict
      if (confirm('A new version of the application is available. Reload to update?')) {
        window.location.reload();
      } else {
        // Optionally, you can delay the reload or handle it differently
      }
    });
    
  2. Version Check Before Making Requests:

    • Implement a mechanism to check the current version of the application before making any requests. This can be done by storing the current version in a meta tag or a global JavaScript variable and comparing it with the server's version.
    const currentVersion = document.querySelector('meta[name="app-version"]').getAttribute('content');
    
    function checkVersionAndProceed() {
      fetch('/api/version')
        .then(response => response.json())
        .then(data => {
          if (data.version !== currentVersion) {
            alert('A new version is available. Please refresh the page.');
          } else {
            // Proceed with the request
          }
        });
    }
    
  3. User Notification and Deferred Reload:

    • Notify users about the availability of a new version and give them the option to reload at their convenience. This can be done using a non-intrusive notification or modal.
    function notifyUserOfNewVersion() {
      const notification = document.createElement('div');
      notification.innerHTML = 'A new version is available. <button onclick="window.location.reload()">Reload</button>';
      document.body.appendChild(notification);
    }
    
  4. Session Persistence:

    • Ensure that the video session state is preserved across reloads. This can be achieved by storing session data in local storage or using a backend mechanism to restore the session after a reload.
  5. Feature Flags and Graceful Degradation:

    • Use feature flags to control the deployment of new features and ensure backward compatibility. This allows you to deploy changes without immediately affecting all users.

By implementing these strategies, you can minimize disruptions during deployments and provide a smoother user experience in your video conferencing application.

Please or to participate in this conversation.