web api event
EventSource: error event
Available in workers
The error event of the EventSource API is fired when a connection with an event source fails to be opened.
This event is not cancelable and does not bubble.
Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("error", (event) => { })
onerror = (event) => { }
Event type
A generic Event.
Examples
const evtSource = new EventSource("sse.php");
// addEventListener version
evtSource.addEventListener("error", (e) => {
console.log("An error occurred while attempting to connect.");
});
// onerror version
evtSource.onerror = (e) => {
console.log("An error occurred while attempting to connect.");
};
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.