My interest is handling sites only during heavy load times for autofills to work. For example, when a sale opens and the site is swarmed, it sometimes crashes. I need to catch the site errors, so I can reload the page from the background script. As described in Chrome Extensions: Background Script Catch Network and HTTP Errors, we can get the page load errors.
Page load error can be due to network issues, site issues, DNS issues, and also due to site overload issues.
All I want is to reload the web page in case it has not loaded due to some error.
I've collected many error codes for both Chrome and Firefox:
- net::ERR_ABORTED
- net::ERR_EMPTY_RESPONSE
- net::ERR_CONNECTION_TIMED_OUT
- net::ERR_CONNECTION_REFUSED
- net::ERR_CONNECTION_RESET
- NS_ERROR_NET_ON_CONNECTING_TO
- NS_ERROR_NET_ON_WAITING_FOR
- NS_ERROR_NET_ON_CONNECTING_TO
This is not the full list. I've seen these errors, so I've listed them. Instead of finding them using trial and error, I want to know the list of all error codes when a (HTML) page won't load.
Here is the sample source code how I'd like to use:
chrome.webRequest.onErrorOccurred.addListener(function (details)
{
if ("type" in details && ['main_frame', 'sub_frame'].indexOf(details.type) == -1)
{
if (details.url.match(/.js$/))
{
console.log("Error in download of this file:", details.url);
}
return;
}
if (details.tabId == -1)
{
return;
}
var check_all_errors = function(err)
{
var all_errors = [
"net::ERR_ABORTED",
"net::ERR_EMPTY_RESPONSE",
"net::ERR_CONNECTION_TIMED_OUT",
"net::ERR_CONNECTION_REFUSED",
"net::ERR_CONNECTION_RESET",
"NS_ERROR_NET_ON_CONNECTING_TO",
'NS_ERROR_NET_ON_WAITING_FOR',
'NS_ERROR_NET_ON_CONNECTING_TO'
];
for( var i=0;i<all_errors.length;++i)
{
if( all_errors[i] == err && !ff_validate_false())
{
return true;
}
}
console.log("786 returning false for err "+err);
return false;
}
if (details.url == HOME_URL && check_all_errors(details.error)) //if any error encountered then go to home URL
{
setTimeout(function () {
chrome.tabs.update(details.tabId, {url: HOME_URL});
}, 1000);
}
//FOLLOWING PART IS NOW SHOWN HERE
My interest is handling sites only during heavy load times for autofills to work. For example, when a sale opens and the site is swarmed, it sometimes crashes. I need to catch the site errors, so I can reload the page from the background script. As described in Chrome Extensions: Background Script Catch Network and HTTP Errors, we can get the page load errors.
Page load error can be due to network issues, site issues, DNS issues, and also due to site overload issues.
All I want is to reload the web page in case it has not loaded due to some error.
I've collected many error codes for both Chrome and Firefox:
- net::ERR_ABORTED
- net::ERR_EMPTY_RESPONSE
- net::ERR_CONNECTION_TIMED_OUT
- net::ERR_CONNECTION_REFUSED
- net::ERR_CONNECTION_RESET
- NS_ERROR_NET_ON_CONNECTING_TO
- NS_ERROR_NET_ON_WAITING_FOR
- NS_ERROR_NET_ON_CONNECTING_TO
This is not the full list. I've seen these errors, so I've listed them. Instead of finding them using trial and error, I want to know the list of all error codes when a (HTML) page won't load.
Here is the sample source code how I'd like to use:
chrome.webRequest.onErrorOccurred.addListener(function (details)
{
if ("type" in details && ['main_frame', 'sub_frame'].indexOf(details.type) == -1)
{
if (details.url.match(/.js$/))
{
console.log("Error in download of this file:", details.url);
}
return;
}
if (details.tabId == -1)
{
return;
}
var check_all_errors = function(err)
{
var all_errors = [
"net::ERR_ABORTED",
"net::ERR_EMPTY_RESPONSE",
"net::ERR_CONNECTION_TIMED_OUT",
"net::ERR_CONNECTION_REFUSED",
"net::ERR_CONNECTION_RESET",
"NS_ERROR_NET_ON_CONNECTING_TO",
'NS_ERROR_NET_ON_WAITING_FOR',
'NS_ERROR_NET_ON_CONNECTING_TO'
];
for( var i=0;i<all_errors.length;++i)
{
if( all_errors[i] == err && !ff_validate_false())
{
return true;
}
}
console.log("786 returning false for err "+err);
return false;
}
if (details.url == HOME_URL && check_all_errors(details.error)) //if any error encountered then go to home URL
{
setTimeout(function () {
chrome.tabs.update(details.tabId, {url: HOME_URL});
}, 1000);
}
//FOLLOWING PART IS NOW SHOWN HERE
Share
Improve this question
edited May 23, 2017 at 12:09
CommunityBot
11 silver badge
asked Feb 18, 2017 at 19:54
user5858user5858
1,2217 gold badges42 silver badges84 bronze badges
9
- Please explain why using the code in the answer to the question you linked did not work for you. – Makyen ♦ Commented Feb 18, 2017 at 22:43
- Based on the results of simple Google searches using text from your question, you appear to have not tried to find a list of codes yourself. Many different Google searches will get you pages which list the various possible error codes, and their descriptions. For instance: List of HTTP status codes, which includes unofficial codes. Note: You currently are listing the description text of the error, not the status code. It will probably be easier for you to detect the actual 4xx or 5xx status code, not the descriptive text. – Makyen ♦ Commented Feb 18, 2017 at 22:52
- @Makyen I need code names like: net::ERR_EMPTY_RESPONSE not the http codes – user5858 Commented Feb 19, 2017 at 5:33
- I'm curious, why do you need them instead of the codes? What code are you using that shows those errors? Note that these do not appear to be from Firefox, as none of the ones you list, that are specific enough to make a reasonable search term, appear to be in the Firefox source code. At least some of them match in the Chrome source code (that link will have a list of a reasonable number of them). – Makyen ♦ Commented Feb 19, 2017 at 8:09
- @Makyen see you yourself don't know the Firefox error codes etc .. why you downvoted? I've asked this question to get a clear answer about the codes. I've already collected many. – user5858 Commented Feb 19, 2017 at 13:39
1 Answer
Reset to default 8It is strongly remended that you do not do this
For the error
property (MDN) provided in the details
object (MDN) passed to a webRequest.onErrorOccurred
(MDN) listener, it is strongly remended that you not test the actual text contents of that property.
Chrome
The Chrome source code says:
You must not parse and act based upon its content.
In this line of code:
"error": {"type": "string", "description": "The error description. This string is <em>not</em> guaranteed to remain backwards patible between releases. You must not parse and act based upon its content."}
The documentation says:
The error description. This string is not guaranteed to remain backwards patible between releases. You must not parse and act based upon its content.
Firefox
The Firefox source code states:
You must not parse and act based upon its content.
In this line of code:
"error": {"type": "string", "description": "The error description. This string is <em>not</em> guaranteed to remain backwards patible between releases. You must not parse and act based upon its content."}
The documentation says:
The error description. This string is an internal error string, may vary from one browser to another, and is not guaranteed to stay the same between releases.
Current possible error
values
Chrome
Chrome has their list of possible error values in this file (some associated code). That code is:
{ net::ERR_ABORTED, "aborted" },
{ net::ERR_TIMED_OUT, "tcp.connection.timed_out" },
{ net::ERR_CONNECTION_CLOSED, "tcp.connection.closed" },
{ net::ERR_CONNECTION_RESET, "tcp.connection.reset" },
{ net::ERR_CONNECTION_REFUSED, "tcp.connection.refused" },
{ net::ERR_CONNECTION_ABORTED, "tcp.connection.aborted" },
{ net::ERR_CONNECTION_FAILED, "tcp.connection.failed" },
{ net::ERR_NAME_NOT_RESOLVED, "dns" },
{ net::ERR_SSL_PROTOCOL_ERROR, "ssl.protocol.error" },
{ net::ERR_ADDRESS_INVALID, "tcp.connection.address_invalid" },
{ net::ERR_ADDRESS_UNREACHABLE, "tcp.connection.address_unreachable" },
{ net::ERR_CONNECTION_TIMED_OUT, "tcp.connection.timed_out" },
{ net::ERR_NAME_RESOLUTION_FAILED, "dns" },
{ net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN,
"ssl.cert.pinned_key_not_in_cert_chain" },
{ net::ERR_CERT_COMMON_NAME_INVALID, "ssl.cert.name_invalid" },
{ net::ERR_CERT_DATE_INVALID, "ssl.cert.date_invalid" },
{ net::ERR_CERT_AUTHORITY_INVALID, "ssl.cert.authority_invalid" },
{ net::ERR_CERT_REVOKED, "ssl.cert.revoked" },
{ net::ERR_CERT_INVALID, "ssl.cert.invalid" },
{ net::ERR_EMPTY_RESPONSE, "http.response.empty" },
{ net::ERR_SPDY_PING_FAILED, "spdy.ping_failed" },
{ net::ERR_SPDY_PROTOCOL_ERROR, "spdy.protocol" },
{ net::ERR_QUIC_PROTOCOL_ERROR, "quic.protocol" },
{ net::ERR_DNS_MALFORMED_RESPONSE, "dns.protocol" },
{ net::ERR_DNS_SERVER_FAILED, "dns.server" },
{ net::ERR_DNS_TIMED_OUT, "dns.timed_out" },
{ net::ERR_INSECURE_RESPONSE, "ssl" },
{ net::ERR_CONTENT_LENGTH_MISMATCH, "http.response.content_length_mismatch" },
{ net::ERR_INCOMPLETE_CHUNKED_ENCODING,
"http.response.inplete_chunked_encoding" },
{ net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH,
"ssl.version_or_cipher_mismatch" },
{ net::ERR_BAD_SSL_CLIENT_AUTH_CERT, "ssl.bad_client_auth_cert" },
{ net::ERR_INVALID_CHUNKED_ENCODING,
"http.response.invalid_chunked_encoding" },
{ net::ERR_RESPONSE_HEADERS_TRUNCATED, "http.response.headers.truncated" },
{ net::ERR_REQUEST_RANGE_NOT_SATISFIABLE,
"http.request.range_not_satisfiable" },
{ net::ERR_INVALID_RESPONSE, "http.response.invalid" },
{ net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION,
"http.response.headers.multiple_content_disposition" },
{ net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH,
"http.response.headers.multiple_content_length" },
{ net::ERR_SSL_UNRECOGNIZED_NAME_ALERT, "ssl.unrecognized_name_alert" }
That means the possible values for Chrome are:
net::ERR_ABORTED
net::ERR_TIMED_OUT
net::ERR_CONNECTION_CLOSED
net::ERR_CONNECTION_RESET
net::ERR_CONNECTION_REFUSED
net::ERR_CONNECTION_ABORTED
net::ERR_CONNECTION_FAILED
net::ERR_NAME_NOT_RESOLVED
net::ERR_SSL_PROTOCOL_ERROR
net::ERR_ADDRESS_INVALID
net::ERR_ADDRESS_UNREACHABLE
net::ERR_CONNECTION_TIMED_OUT
net::ERR_NAME_RESOLUTION_FAILED
net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN
net::ERR_CERT_COMMON_NAME_INVALID
net::ERR_CERT_DATE_INVALID
net::ERR_CERT_AUTHORITY_INVALID
net::ERR_CERT_REVOKED
net::ERR_CERT_INVALID
net::ERR_EMPTY_RESPONSE
net::ERR_SPDY_PING_FAILED
net::ERR_SPDY_PROTOCOL_ERROR
net::ERR_QUIC_PROTOCOL_ERROR
net::ERR_DNS_MALFORMED_RESPONSE
net::ERR_DNS_SERVER_FAILED
net::ERR_DNS_TIMED_OUT
net::ERR_INSECURE_RESPONSE
net::ERR_CONTENT_LENGTH_MISMATCH
net::ERR_INCOMPLETE_CHUNKED_ENCODING
net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH
net::ERR_BAD_SSL_CLIENT_AUTH_CERT
net::ERR_INVALID_CHUNKED_ENCODING
net::ERR_RESPONSE_HEADERS_TRUNCATED
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE
net::ERR_INVALID_RESPONSE
net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH
net::ERR_SSL_UNRECOGNIZED_NAME_ALERT
Firefox
Firefox is a bit more plex. WebExtensions is an API layered on top of the APIs that Firefox uses (and exposes to other types of add-ons). The Firefox code changes the error-text responses it gets from the underlying API by:
let prefix = /^(?:ACTIVITY_SUBTYPE_|STATUS_)/;
let map = new Map();
for (let iface of [nsIHttpActivityObserver, nsISocketTransport]) {
for (let c of Object.keys(iface).filter(name => prefix.test(name))) {
map.set(iface[c], c.replace(prefix, "NS_ERROR_NET_ON_"));
}
}
The code for the possible ACTIVITY_SUBTYPE_
properties is in the file nsIHttpActivityObserver.idl and the definitions for the possible STATUS_
properties is in nsISocketTransport.idl. Performing the appropriate RegEx substitution results in the following possible values:
NS_ERROR_NET_ON_RESOLVING
NS_ERROR_NET_ON_RESOLVED
NS_ERROR_NET_ON_CONNECTING_TO
NS_ERROR_NET_ON_CONNECTED_TO
NS_ERROR_NET_ON_SENDING_TO
NS_ERROR_NET_ON_WAITING_FOR
NS_ERROR_NET_ON_RECEIVING_FROM
NS_ERROR_NET_ON_REQUEST_HEADER
NS_ERROR_NET_ON_REQUEST_BODY_SENT
NS_ERROR_NET_ON_RESPONSE_START
NS_ERROR_NET_ON_RESPONSE_HEADER
NS_ERROR_NET_ON_RESPONSE_COMPLETE
NS_ERROR_NET_ON_TRANSACTION_CLOSE