Skip to content

Commit

Permalink
Upgrade to latest version of socket.io. Fixes #1847
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh committed Feb 24, 2022
1 parent a7c14c8 commit 3c5777a
Show file tree
Hide file tree
Showing 4 changed files with 6,817 additions and 6,619 deletions.
13 changes: 13 additions & 0 deletions packages/browser-sync-ui/public/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*! https://mths.be/utf8js v2.1.2 by @mathias */

/**
* @license AngularJS v1.4.14
* (c) 2010-2015 Google, Inc. http://angularjs.org
* License: MIT
*/

/**
* @license AngularJS v1.8.2
* (c) 2010-2020 Google LLC. http://angularjs.org
* License: MIT
*/
22 changes: 13 additions & 9 deletions packages/browser-sync/lib/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@ module.exports.init = function(server, clientEvents, bs) {

var socketIoConfig = socketConfig.socketIoOptions;
socketIoConfig.path = socketConfig.path;
// set pingTimeout from clients.heartbeatTimeout after heartbeat reversal in engine.io@4
// https://socket.io/blog/engine-io-4-release/#Heartbeat-mechanism-reversal
socketIoConfig.pingTimeout = socketConfig.clients.heartbeatTimeout;
// enable cors for any domain after socket.io@3
// https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#cors-handling
socketIoConfig.cors = {
origins: (origin, callback) => callback(null, origin)
}

// create instance of socket.io Server
var io = socket(server, socketIoConfig);
// move internal sockets property back to connected to maintain backwards compatibility after socket.io@3
// https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#namespaceconnected-is-renamed-to-namespacesockets-and-is-now-a-map

// Override default namespace.
io.sockets = io.of(socketConfig.namespace);

io.set("heartbeat interval", socketConfig.clients.heartbeatTimeout);

// Breaking change was introduced https://socket.io/blog/socket-io-2-4-0/
io.origins((_, callback) => {
callback(null, true);
});
io.connected = io.sockets
io.sockets = io.of(socketConfig.namespace)

/**
* Listen for new connections
Expand Down
Loading

0 comments on commit 3c5777a

Please sign in to comment.