🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

braid-http

Package Overview
Dependencies
Maintainers
0
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

braid-http - npm Package Compare versions

Comparing version

to
1.3.51

83

braid-http-client.js

@@ -269,6 +269,10 @@

e.name !== "AbortError" && // don't retry if the user has chosen to abort
!e.startsWith?.('Parse error in headers') && // in this case, the server is spewing garbage, so reconnecting might be bad
!e.message?.startsWith?.('Could not establish multiplexed request') && // the server has told us no, or is using a different version of multiplexing
!cb_running // if an error is thrown in the callback, then it may not be good to reconnect, and generate more errors
!e.dont_retry && // some errors are unlikely to be fixed by retrying
!cb_running // if an error is thrown in the callback,
// then it may not be good to reconnect, and generate more errors
// some errors can be fixed by changing something, and retrying right away,
// for instance, for a duplicate multiplexer request id
if (e.dont_wait) waitTime = 0
if (retry && !original_signal?.aborted) {

@@ -282,3 +286,3 @@ // retry after some time..

// then we want to return that as the error..
if (retry && original_signal?.aborted) e = create_abort_error('already aborted')
if (retry && original_signal?.aborted) e = create_error('already aborted', {name: 'AbortError'})

@@ -293,3 +297,3 @@ // let people know things are shutting down..

try {
if (original_signal?.aborted) throw create_abort_error('already aborted')
if (original_signal?.aborted) throw create_error('already aborted', {name: 'AbortError'})

@@ -310,3 +314,3 @@ // We need a fresh underlying abort controller each time we connect

// to display them for the user in the dev panel
params.onFetch?.(url, params)
params.onFetch?.(url, params, underlying_aborter)

@@ -370,3 +374,3 @@ // Now we run the original fetch....

if (original_signal?.aborted)
throw create_abort_error('already aborted')
throw create_error('already aborted', {name: 'AbortError'})

@@ -450,15 +454,12 @@ // Yay! We got a new version! Tell the callback!

if (give_up) {
let e = new Error(`giving up because of http status: ${res.status}${(res.status === 401 || res.status === 403) ? ` (access denied)` : ''}`)
subscription_error?.(e)
return fail(e)
}
if (!res.ok) throw new Error(`status not ok: ${res.status}`)
if (subscription_cb) subscription_error?.(new Error(`giving up because of http status: ${res.status}${(res.status === 401 || res.status === 403) ? ` (access denied)` : ''}`))
} else if (!res.ok) throw new Error(`status not ok: ${res.status}`)
}
if (subscription_cb) start_subscription(subscription_cb, subscription_error)
if (subscription_cb && res.ok) start_subscription(subscription_cb, subscription_error)
done(res)
params?.retry?.onRes?.(res)
waitTime = 1
done(res)
} catch (e) { on_error(e) }

@@ -575,3 +576,3 @@ }

else if (this.state.result === 'error') {
await this.cb(null, this.state.message)
await this.cb(null, create_error(this.state.message, {dont_retry: true}))
return

@@ -882,5 +883,5 @@ }

function create_abort_error(msg) {
function create_error(msg, override) {
var e = new Error(msg)
e.name = 'AbortError'
if (override) Object.assign(e, override)
return e

@@ -969,3 +970,3 @@ }

if (e.error === 'Multiplexer already exists')
return cleanup(new Error(e.error))
return cleanup(create_error(e.error, {dont_wait: true}))
}

@@ -985,3 +986,3 @@ if (!r.ok || r.headers.get('Multiplex-Version') !== multiplex_version)

if (e.error === 'Multiplexer already exists')
return cleanup(new Error(e.error))
return cleanup(create_error(e.error, {dont_wait: true}))
}

@@ -1073,9 +1074,16 @@ if (!r.ok) throw new Error('status not ok: ' + r.status)

if (res.status === 409) {
var e = await r.json()
if (e.error === 'Request already multiplexed') throw new Error(e.error)
var e = await res.json()
if (e.error === 'Request already multiplexed') {
// the id is already in use,
// so we want to retry right away with a different id
throw create_error(e.error, {dont_wait: true})
}
}
if (res.status === 424) {
// this error will trigger a retry if the user is using that option
throw new Error('multiplexer not yet connected')
// the multiplexer isn't there,
// could be we arrived before the multiplexer,
// or after it was shutdown;
// in either case we want to retry right away
throw create_error('multiplexer not connected', {dont_wait: true})
}

@@ -1089,11 +1097,13 @@

if (res.status !== 293)
throw new Error('Could not establish multiplexed request '
+ params.headers.get('multiplex-through')
+ ', got status: ' + res.status)
throw create_error('Could not establish multiplexed request '
+ params.headers.get('multiplex-through')
+ ', got status: ' + res.status,
{ dont_retry: true })
if (res.headers.get('Multiplex-Version') !== multiplex_version)
throw new Error('Could not establish multiplexed request '
+ params.headers.get('multiplex-through')
+ ', got unknown version: '
+ res.headers.get('Multiplex-Version'))
throw create_error('Could not establish multiplexed request '
+ params.headers.get('multiplex-through')
+ ', got unknown version: '
+ res.headers.get('Multiplex-Version'),
{ dont_retry: true })

@@ -1103,4 +1113,4 @@ // we want to present the illusion that the connection is still open,

// so we handle the abort ourselves to close the multiplexed request
params.signal?.addEventListener('abort', () =>
unset(create_abort_error('request aborted')))
params.signal.addEventListener('abort', () =>
unset(create_error('request aborted', {name: 'AbortError'})))

@@ -1151,8 +1161,7 @@ // first, we need to listen for the headers..

var b = buffers.shift()
if (!b) {
if (mux_error || request_error) controller.error(mux_error || request_error)
return true
}
if (!b) return true
controller.enqueue(b)
})
} catch (e) {
controller.error(e)
} finally { controller.close() }

@@ -1159,0 +1168,0 @@ }

{
"name": "braid-http",
"version": "1.3.50",
"version": "1.3.51",
"description": "An implementation of Braid-HTTP for Node.js and Browsers",

@@ -5,0 +5,0 @@ "scripts": {