Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: socketio/engine.io-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9eeed5e
Choose a base ref
...
head repository: socketio/engine.io-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0acbe5f
Choose a head ref
  • 3 commits
  • 11 files changed
  • 1 contributor

Commits on May 4, 2021

  1. feat: add the "closeOnBeforeunload" option

    Since [1], the socket is now closed when receiving the "beforeunload"
    event in the browser.
    
    This change was meant to fix a discrepancy between Chrome and Firefox
    when the user reloads/closes a browser tab: Firefox would close the
    connection (and emit a "disconnect" event, at the Socket.IO level), but
    not Chrome (see [2]).
    
    But it also closes the connection when there is another "beforeunload"
    handler, for example when the user is prompted "are you sure you want
    to leave this page?".
    
    Note: calling "stopImmediatePropagation()" was a possible workaround:
    
    ```js
    window.addEventListener('beforeunload', (event) => {
      event.preventDefault();
      event.stopImmediatePropagation();
      event.returnValue = 'are you sure you want to leave this page?';
    });
    ```
    
    This commit adds a "closeOnBeforeunload" option, which controls whether
    a handler is registered for the "beforeunload" event.
    
    Syntax:
    
    ```js
    const socket = require('engine.io-client')('ws://localhost', {
      closeOnBeforeunload: false // defaults to true
    });
    ```
    
    [1]: ed48b5d
    [2]: socketio/socket.io#3639
    
    Related:
    
    - #661
    - #658
    - socketio/socket.io-client#1451
    
    Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
    darrachequesne committed May 4, 2021
    Configuration menu
    Copy the full SHA
    dcb85e9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c46611c View commit details
    Browse the repository at this point in the history
  3. chore(release): 5.1.0

    darrachequesne committed May 4, 2021
    Configuration menu
    Copy the full SHA
    0acbe5f View commit details
    Browse the repository at this point in the history
Loading