Files
cypress/packages/socket/lib/socket.ts
Zach Bloomquist d01932bf75 fix: retry on EMFILE always, lint sync FS calls (#22175)
* fix: use graceful-fs always, warn in development on sync calls

* skip prop linting in some dirs

* eslint rules

* use AST-based lint rule instead

* comment

* ignore existsSync

* run without nextTick

* remove dev warning code

* fix order

* register TS first

* fix tests

* fix test

* cover new call site

* fix new test
2022-06-16 14:35:31 +10:00

42 lines
1.2 KiB
TypeScript

import buffer from 'buffer'
import type http from 'http'
import server, { Server as SocketIOBaseServer, ServerOptions, Socket, Namespace } from 'socket.io'
export type { Socket, Namespace as SocketIONamespace }
const { version } = require('socket.io-client/package.json')
const clientSource = require.resolve('socket.io-client/dist/socket.io.js')
export { ServerOptions }
// socket.io types are incorrect
type PatchedServerOptions = ServerOptions & { cookie: { name: string | boolean } }
class SocketIOServer extends SocketIOBaseServer {
constructor (srv: http.Server, opts?: Partial<PatchedServerOptions>) {
opts = opts ?? {}
// the maxHttpBufferSize is used to limit the message size sent over
// the socket. Small values can be used to mitigate exposure to
// denial of service attacks; the default as of v3.0 is 1MB.
// because our server is local, we do not need to arbitrarily limit
// the message size and can use the theoretical maximum value.
opts.maxHttpBufferSize = opts.maxHttpBufferSize ?? buffer.constants.MAX_LENGTH
super(srv, opts)
}
}
export {
server,
SocketIOServer,
}
export const getPathToClientSource = () => {
return clientSource
}
export const getClientVersion = () => {
return version
}