Skip to content
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

Bug fix for program crash #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Releases

- [0.2.1](#021-2024-08-27) (2024-08-27)
- [0.2.0](#020-2022-10-11) (2022-10-11)
- [0.1.1](#011-2022-09-14) (2022-09-14)
- [0.1.0](#010-2022-09-12) (2022-09-12)

# [0.2.1](https://github.com/itsfuad/socket.io-deno/compare/0.2.0...0.2.1) (2024-08-27)

### Bug Fixes

- **engine:** Add check for readyState before sending packets

# [0.2.0](https://github.com/socketio/socket.io-deno/compare/0.1.1...0.2.0) (2022-10-11)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine.io/lib/transports/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class WS extends Transport {
public send(packets: Packet[]) {
for (const packet of packets) {
Parser.encodePacket(packet, true, (data: RawData) => {
if (this.writable) {
if (this.writable && this.readyState === "open") {
this.socket?.send(data);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/msgpack/lib/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function utf8Read(view: DataView, offset: number, length: number) {

class Decoder {
public _offset = 0;
private readonly _buffer: ArrayBuffer;
private readonly _buffer: ArrayBuffer | SharedArrayBuffer;
private readonly _view: DataView;

constructor(buffer: ArrayBuffer | ArrayBufferView) {
Expand Down
4 changes: 2 additions & 2 deletions packages/msgpack/lib/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function utf8Length(str: string) {
type DeferredElement = {
_str?: string;
_float?: number;
_bin?: ArrayBuffer;
_bin?: ArrayBuffer | ArrayBufferLike;
_length: number;
_offset: number;
};
Expand All @@ -60,7 +60,7 @@ function _encodeObject(
return _encode(bytes, defers, (value.toJSON as unknown as () => unknown)());
}

const keys = [];
const keys: any[] = [];
let key: string;

const allKeys = Object.keys(value);
Expand Down
7 changes: 0 additions & 7 deletions packages/socket.io/lib/parent-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ export class ParentNamespace<
server: Server<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
) {
super(server, "/_" + ParentNamespace.count++);
// this.adapter = {
// broadcast(packet: Packet, opts: BroadcastOptions) {
// this.children.forEach((nsp: Namespace) => {
// nsp.adapter.broadcast(packet, opts);
// });
// }
// };
}

public emit<Ev extends EventNames<EmitEvents>>(
Expand Down
6 changes: 3 additions & 3 deletions packages/socket.io/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export interface ServerOptions {
}

export interface ServerReservedEvents<
ListenEvents,
EmitEvents,
ServerSideEvents,
ListenEvents extends EventsMap,
EmitEvents extends EventsMap,
ServerSideEvents extends EventsMap,
SocketData,
> extends
NamespaceReservedEvents<
Expand Down