braid-http 1.3.107 → 1.3.108

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.
@@ -324,13 +324,18 @@ async function braid_fetch (url, params = {}) {
324
324
  if (!is_nodejs && params.headers.has('subscribe')) {
325
325
  var nav_entry = performance?.getEntriesByType?.('navigation')?.[0]
326
326
  if (nav_entry?.type === 'back_forward'
327
- && document.readyState !== 'complete')
327
+ && document.readyState !== 'complete') {
328
+
329
+ // ...we wait until the page has loaded to send this fetch,
330
+ // because Chrome's SKIP_CACHE_VALIDATION policy goes away
331
+ // once the page loads.
328
332
 
329
- // ...we just wait until the page has loaded to send this fetch
330
333
  await new Promise(r => window.addEventListener('load', r))
331
334
 
332
- // Because the SKIP_CACHE_VALIDATION policy in chrome goes away
333
- // as soon as the page loads.
335
+ // In practice, waiting for 'load' alone isn't enough;
336
+ // we also need this setTimeout(0) for it to work reliably.
337
+ await new Promise(done => setTimeout(done, 0))
338
+ }
334
339
  }
335
340
 
336
341
  // Braid-Chrome needs the following special (undocumented)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.107",
3
+ "version": "1.3.108",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/test.js",