mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(ext/websocket): initialize error
attribute of WebSocket ErrorEvent (#26796)
Fixes https://github.com/denoland/deno/issues/26216 Not required by the spec but Discord.js depends on it, see https://github.com/denoland/deno/issues/26216#issuecomment-2466060306
This commit is contained in:
parent
c3c2b37966
commit
3b99f6833c
2 changed files with 7 additions and 2 deletions
|
@ -28,6 +28,7 @@ const {
|
|||
ArrayPrototypePush,
|
||||
ArrayPrototypeShift,
|
||||
ArrayPrototypeSome,
|
||||
Error,
|
||||
ErrorPrototypeToString,
|
||||
ObjectDefineProperties,
|
||||
ObjectPrototypeIsPrototypeOf,
|
||||
|
@ -488,8 +489,11 @@ class WebSocket extends EventTarget {
|
|||
/* error */
|
||||
this[_readyState] = CLOSED;
|
||||
|
||||
const message = op_ws_get_error(rid);
|
||||
const error = new Error(message);
|
||||
const errorEv = new ErrorEvent("error", {
|
||||
message: op_ws_get_error(rid),
|
||||
error,
|
||||
message,
|
||||
});
|
||||
this.dispatchEvent(errorEv);
|
||||
|
||||
|
|
|
@ -453,7 +453,8 @@ Deno.test("invalid server", async () => {
|
|||
const { promise, resolve } = Promise.withResolvers<void>();
|
||||
const ws = new WebSocket("ws://localhost:2121");
|
||||
let err = false;
|
||||
ws.onerror = () => {
|
||||
ws.onerror = (e) => {
|
||||
assert("error" in e);
|
||||
err = true;
|
||||
};
|
||||
ws.onclose = () => {
|
||||
|
|
Loading…
Reference in a new issue