braid-http 1.3.12 → 1.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,11 @@
1
+ Invisible Property License
2
+
3
+ 1. You have the right to use this IP for any purpose.
4
+ 2. If you make profit, you agree to give back a fair share of the profit to
5
+ the creators of this IP.
6
+ 3. The creators will tell you how much they think is a fair share, if your
7
+ usage matters to them, and promise not to take you to court to enforce
8
+ the agreement.
9
+
10
+ (In other words, this license thus runs on the honor system. You are invited
11
+ to participate in our community with honor.)
@@ -116,22 +116,11 @@ function braidify_http (http) {
116
116
  // ***************************
117
117
 
118
118
  var normal_fetch,
119
- AbortController,
120
- Headers,
121
119
  is_nodejs = typeof window === 'undefined'
122
120
 
123
121
  if (is_nodejs) {
124
122
  // Nodejs
125
-
126
- // Note that reconnect logic doesn't work in node-fetch, because it
127
- // doesn't call the .catch() handler when the stream fails.
128
- //
129
- // See https://github.com/node-fetch/node-fetch/issues/753
130
-
131
- normal_fetch = require('node-fetch')
132
- AbortController = require('abort-controller')
133
- Headers = normal_fetch.Headers
134
- var to_whatwg_stream = require('web-streams-node').toWebReadableStream
123
+ normal_fetch = fetch
135
124
  } else {
136
125
  // Web Browser
137
126
  normal_fetch = window.fetch
@@ -233,7 +222,7 @@ async function braid_fetch (url, params = {}) {
233
222
  () => underlying_aborter.abort()
234
223
  )
235
224
 
236
- var waitTime = 10
225
+ var waitTime = 1
237
226
  var res = null
238
227
  var subscription_cb = null
239
228
  var subscription_error = null
@@ -251,9 +240,9 @@ async function braid_fetch (url, params = {}) {
251
240
 
252
241
  underlying_aborter.abort()
253
242
 
254
- console.log(`retrying in ${waitTime}ms: ${url} after error: ${e}`)
255
- setTimeout(connect, waitTime)
256
- waitTime = Math.min(waitTime * 2, 3000)
243
+ console.log(`retrying in ${waitTime}s: ${url} after error: ${e}`)
244
+ setTimeout(connect, waitTime * 1000)
245
+ waitTime = Math.min(waitTime + 1, 3)
257
246
  }
258
247
 
259
248
  try {
@@ -410,7 +399,7 @@ async function braid_fetch (url, params = {}) {
410
399
  done(res)
411
400
 
412
401
  params?.retry?.onRes?.(res)
413
- waitTime = 10
402
+ waitTime = 1
414
403
  } catch (e) { on_error(e) }
415
404
  }
416
405
  })
@@ -418,9 +407,6 @@ async function braid_fetch (url, params = {}) {
418
407
 
419
408
  // Parse a stream of versions from the incoming bytes
420
409
  async function handle_fetch_stream (stream, cb, on_bytes) {
421
- if (is_nodejs)
422
- stream = to_whatwg_stream(stream)
423
-
424
410
  // Set up a reader
425
411
  var reader = stream.getReader(),
426
412
  parser = subscription_parser(cb)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"