Skip to content

Commit c052f44

Browse files
committed
use a parser that supports circular json
1 parent 81309fc commit c052f44

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

packages/extension/app/background.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ map = require("lodash/map")
22
pick = require("lodash/pick")
33
once = require("lodash/once")
44
Promise = require("bluebird")
5+
{ circularParser } = require("@packages/socket")
56

67
HOST = "CHANGE_ME_HOST"
78
PATH = "CHANGE_ME_PATH"
@@ -41,7 +42,11 @@ connect = (host, path, io) ->
4142

4243
## cannot use required socket here due
4344
## to bug in socket io client with browserify
44-
client = io.connect(host, {path: path, transports: ["websocket"]})
45+
client = io.connect(host, {
46+
path: path,
47+
transports: ["websocket"]
48+
parser: circularParser
49+
})
4550

4651
client.on "automation:request", (id, msg, data) ->
4752
switch msg

packages/runner/src/lib/event-manager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import $Cypress, { $ } from '@packages/driver'
1212
const channel = io.connect({
1313
path: '/__socket.io',
1414
transports: ['websocket'],
15+
parser: io.circularParser,
1516
})
1617

1718
channel.on('connect', () => {

packages/server/lib/socket.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Socket
124124
destroyUpgrade: false
125125
serveClient: false
126126
cookie: cookie
127+
parser: socketIo.circularParser
127128
})
128129

129130
startListening: (server, automation, config, options) ->

packages/server/test/integration/websockets_spec.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ describe "Web Sockets", ->
175175
@wsClient = socketIo.client(@cfg.proxyUrl, {
176176
path: @cfg.socketIoRoute
177177
transports: ["websocket"]
178+
parser: socketIo.circularParser
178179
})
179180
@wsClient.on "connect", -> done()
180181

@@ -197,6 +198,7 @@ describe "Web Sockets", ->
197198
agent: agent
198199
path: @cfg.socketIoRoute
199200
transports: ["websocket"]
201+
parser: socketIo.circularParser
200202
})
201203
@wsClient.on "connect", -> done()
202204

@@ -220,6 +222,7 @@ describe "Web Sockets", ->
220222
@wsClient = socketIo.client("https://localhost:#{wssPort}", {
221223
agent: agent
222224
path: @cfg.socketIoRoute
225+
parser: socketIo.circularParser
223226
})
224227
@wsClient.on "connect", -> done()
225228

packages/socket/lib/client.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
const circularParser = require('socket.io-circular-parser')
2+
13
module.exports = require('socket.io-client')
4+
5+
module.exports.circularParser = circularParser

packages/socket/lib/socket.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ const server = require('socket.io')
44
const version = require('socket.io-client/package.json').version
55
const clientPath = require.resolve('socket.io-client')
66
const client = require('./client')
7+
const circularParser = require('socket.io-circular-parser')
78

89
module.exports = {
910
server,
1011

1112
client,
1213

14+
circularParser,
15+
1316
getPathToClientSource () {
1417
// clientPath returns the path to socket.io-client/lib/index.js
1518
// so walk up two levels to get to the root

packages/socket/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"lib"
1818
],
1919
"dependencies": {
20-
"socket.io": "1.7.4",
21-
"socket.io-client": "1.7.4"
20+
"socket.io": "2.2.0",
21+
"socket.io-circular-parser": "3.1.2",
22+
"socket.io-client": "2.2.0"
2223
},
2324
"devDependencies": {
2425
"bin-up": "1.2.0",

0 commit comments

Comments
 (0)