use a parser that supports circular json

This commit is contained in:
Zach Bloomquist
2019-06-06 16:04:29 -04:00
parent 81309fcb1e
commit c052f44ec8
7 changed files with 21 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ map = require("lodash/map")
pick = require("lodash/pick")
once = require("lodash/once")
Promise = require("bluebird")
{ circularParser } = require("@packages/socket")
HOST = "CHANGE_ME_HOST"
PATH = "CHANGE_ME_PATH"
@@ -41,7 +42,11 @@ connect = (host, path, io) ->
## cannot use required socket here due
## to bug in socket io client with browserify
client = io.connect(host, {path: path, transports: ["websocket"]})
client = io.connect(host, {
path: path,
transports: ["websocket"]
parser: circularParser
})
client.on "automation:request", (id, msg, data) ->
switch msg

View File

@@ -12,6 +12,7 @@ import $Cypress, { $ } from '@packages/driver'
const channel = io.connect({
path: '/__socket.io',
transports: ['websocket'],
parser: io.circularParser,
})
channel.on('connect', () => {

View File

@@ -124,6 +124,7 @@ class Socket
destroyUpgrade: false
serveClient: false
cookie: cookie
parser: socketIo.circularParser
})
startListening: (server, automation, config, options) ->

View File

@@ -175,6 +175,7 @@ describe "Web Sockets", ->
@wsClient = socketIo.client(@cfg.proxyUrl, {
path: @cfg.socketIoRoute
transports: ["websocket"]
parser: socketIo.circularParser
})
@wsClient.on "connect", -> done()
@@ -197,6 +198,7 @@ describe "Web Sockets", ->
agent: agent
path: @cfg.socketIoRoute
transports: ["websocket"]
parser: socketIo.circularParser
})
@wsClient.on "connect", -> done()
@@ -220,6 +222,7 @@ describe "Web Sockets", ->
@wsClient = socketIo.client("https://localhost:#{wssPort}", {
agent: agent
path: @cfg.socketIoRoute
parser: socketIo.circularParser
})
@wsClient.on "connect", -> done()

View File

@@ -1 +1,5 @@
const circularParser = require('socket.io-circular-parser')
module.exports = require('socket.io-client')
module.exports.circularParser = circularParser

View File

@@ -4,12 +4,15 @@ const server = require('socket.io')
const version = require('socket.io-client/package.json').version
const clientPath = require.resolve('socket.io-client')
const client = require('./client')
const circularParser = require('socket.io-circular-parser')
module.exports = {
server,
client,
circularParser,
getPathToClientSource () {
// clientPath returns the path to socket.io-client/lib/index.js
// so walk up two levels to get to the root

View File

@@ -17,8 +17,9 @@
"lib"
],
"dependencies": {
"socket.io": "1.7.4",
"socket.io-client": "1.7.4"
"socket.io": "2.2.0",
"socket.io-circular-parser": "3.1.2",
"socket.io-client": "2.2.0"
},
"devDependencies": {
"bin-up": "1.2.0",