## normalizeErrorEvent() function [​](/content/docs/sdk/core.normalizeerrorevent#normalizeerrorevent-function "Direct link to normalizeErrorEvent(/index.html) function")

Normalizes the various `error` event shapes dispatched by different `WebSocket` implementations into a single `ErrorEvent` carrying a real `Error`, so downstream listeners always get `message` and `error` regardless of the underlying implementation:

- Browsers dispatch a plain `Event` with no error details (per the WHATWG WebSocket spec).
- Node's `ws` library and Node's built-in (undici) `WebSocket` dispatch an `ErrorEvent` with both `message` and `error`.
- Bun dispatches a plain `Event` with a `message` string but no `error`.

**Signature:**

```typescript
export declare function normalizeErrorEvent(event: Event | ErrorEvent, target: unknown): ErrorEvent;
```

## Parameters [​](/content/docs/sdk/core.normalizeerrorevent#parameters "Direct link to Parameters"/index.html)

| Parameter | Type | Description |
| --- | --- | --- |
| event | Event \| [ErrorEvent](/content/docs/sdk/core.errorevent_2/index.html) | The `error` event as dispatched by the underlying `WebSocket`. |
| target | unknown | The `ReconnectingWebSocket` instance the normalized event is dispatched from. |

**Returns:**

[ErrorEvent](/content/docs/sdk/core.errorevent_2/index.html)

An `ErrorEvent` with a populated `message` and `error.

- [normalizeErrorEvent() function](/content/docs/sdk/core.normalizeerrorevent#normalizeerrorevent-function/index.html)
- [Parameters](/content/docs/sdk/core.normalizeerrorevent#parameters/index.html)
