Skip to content

fix: Remove ws library #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 10 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@
"ci": "run-s test coverage"
},
"dependencies": {
"@supabase/node-fetch": "^2.6.14",
"@types/phoenix": "^1.5.4",
"@types/ws": "^8.5.10",
"ws": "^8.14.2"
"@supabase/node-fetch": "^2.6.14"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.16.2",
"@types/sinon": "^17.0.3",
"@types/phoenix": "^1.5.4",
"@arethetypeswrong/cli": "^0.16.2",
"@vitest/coverage-v8": "^2.0.5",
"eslint": "^7.0.0",
"esm": "^3.2.25",
Expand Down
13 changes: 2 additions & 11 deletions src/RealtimeClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { WebSocket as WSWebSocket } from 'ws'

import {
CHANNEL_EVENTS,
CONNECTION_STATE,
Expand Down Expand Up @@ -60,7 +58,7 @@ interface WebSocketLikeConstructor {
): WebSocketLike
}

type WebSocketLike = WebSocket | WSWebSocket | WSWebSocketDummy
type WebSocketLike = WebSocket | WSWebSocketDummy

interface WebSocketLikeError {
error: any
Expand Down Expand Up @@ -89,7 +87,7 @@ export default class RealtimeClient {
encode: Function
decode: Function
reconnectAfterMs: Function
conn: WebSocketLike | null = null
conn: any | null = null
sendBuffer: Function[] = []
serializer: Serializer = new Serializer()
stateChangeCallbacks: {
Expand Down Expand Up @@ -187,13 +185,6 @@ export default class RealtimeClient {
this.conn = null
},
})

import('ws').then(({ default: WS }) => {
this.conn = new WS(this._endPointURL(), undefined, {
headers: this.headers,
})
this.setupConnection()
})
}

/**
Expand Down
1 change: 0 additions & 1 deletion test/socket.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'assert'
import { describe, beforeEach, afterEach, test } from 'vitest'
import { Server as MockServer, WebSocket as MockWebSocket } from 'mock-socket'
import WebSocket from 'ws'
import sinon from 'sinon'

import RealtimeClient from '../src/RealtimeClient'
Expand Down
Loading