Reject WebSocket connect timeout with an HTTPError
This commit is contained in:
parent
ca330899bb
commit
d4d454e554
1 changed files with 12 additions and 4 deletions
|
@ -305,7 +305,15 @@ async function _connectSocket(
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
reject(new Error('Connection timed out'));
|
reject(
|
||||||
|
makeHTTPError(
|
||||||
|
'_connectSocket: Connection timed out',
|
||||||
|
-1,
|
||||||
|
{},
|
||||||
|
'Connection timed out',
|
||||||
|
stack
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
client.abort();
|
client.abort();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
@ -322,7 +330,7 @@ async function _connectSocket(
|
||||||
await _handleStatusCode(statusCode);
|
await _handleStatusCode(statusCode);
|
||||||
|
|
||||||
const error = makeHTTPError(
|
const error = makeHTTPError(
|
||||||
'promiseAjax: invalid websocket response',
|
'_connectSocket: invalid websocket response',
|
||||||
statusCode || -1,
|
statusCode || -1,
|
||||||
{}, // headers
|
{}, // headers
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -342,8 +350,8 @@ async function _connectSocket(
|
||||||
|
|
||||||
reject(
|
reject(
|
||||||
makeHTTPError(
|
makeHTTPError(
|
||||||
'_connectSocket connectFailed',
|
'_connectSocket: connectFailed',
|
||||||
0,
|
-1,
|
||||||
{},
|
{},
|
||||||
e.toString(),
|
e.toString(),
|
||||||
stack
|
stack
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue