diff --git a/src/js/game.ts b/src/js/game.ts index 52167636..c3dd0ee2 100644 --- a/src/js/game.ts +++ b/src/js/game.ts @@ -3438,7 +3438,7 @@ class Game extends Client { this.pressedContinueOption = true; } } else if (action === 1773) { - // loc examine + // inv obj examine const obj: ObjType = ObjType.get(a); let examine: string; @@ -7816,7 +7816,7 @@ class Game extends Client { } if (count > this.npcCount) { - throw new Error(`eek! ${this.username} Too many npc!`); + throw new Error(`eek! ${this.username} Too many npcs`); } this.npcCount = 0; diff --git a/src/js/jagex2/io/ClientStream.ts b/src/js/jagex2/io/ClientStream.ts index e76d5bbc..963e4981 100644 --- a/src/js/jagex2/io/ClientStream.ts +++ b/src/js/jagex2/io/ClientStream.ts @@ -1,5 +1,6 @@ import LinkList from '../datastruct/LinkList'; import Linkable from '../datastruct/Linkable'; +import {sleep} from '../util/JsUtil'; export type Socket = { host: string; @@ -217,7 +218,12 @@ class WebSocketReader { private async readSlowByte(len: number): Promise { this.event = this.queue.removeHead() as WebSocketEvent | null; while (this.total < len) { - await new Promise((resolve): ((value: PromiseLike<((data: WebSocketEvent | null) => void) | null>) => void) => (this.callback = resolve)); + await Promise.race([ + new Promise((resolve): ((value: PromiseLike<((data: WebSocketEvent | null) => void) | null>) => void) => (this.callback = resolve)), + sleep(2000).then((): void => { + throw new Error('WebSocketReader timed out or closed while reading.'); + }) + ]); } return this.event ? this.event.read : this.readSlowByte(len); }