Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

make-fetch-happen

Package Overview
Dependencies
Maintainers
7
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-fetch-happen - npm Package Compare versions

Comparing version 9.0.3 to 9.0.4

30

lib/cache/entry.js

@@ -51,2 +51,3 @@ const { Request, Response } = require('minipass-fetch')

const metadata = {
time: Date.now(),
url: request.url,

@@ -116,5 +117,14 @@ reqHeaders: {},

constructor ({ entry, request, response, options }) {
this.entry = entry
if (entry) {
this.key = entry.key
this.entry = entry
// previous versions of this module didn't write an explicit timestamp in
// the metadata, so fall back to the entry's timestamp. we can't use the
// entry timestamp to determine staleness because cacache will update it
// when it verifies its data
this.entry.metadata.time = this.entry.metadata.time || this.entry.time
} else
this.key = cacheKey(request)
this.options = options
this.key = entry ? entry.key : cacheKey(request)

@@ -345,2 +355,6 @@ // these properties are behind getters that lazily evaluate

} catch (err) {
if (err.code === 'EINTEGRITY')
await cacache.rm.content(this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize })
if (err.code === 'ENOENT' || err.code === 'EINTEGRITY')
await CacheEntry.invalidate(this.request, this.options)
body.emit('error', err)

@@ -352,3 +366,11 @@ }

const cacheStream = cacache.get.stream.byDigest(this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize })
cacheStream.on('error', (err) => body.emit('error', err))
cacheStream.on('error', async (err) => {
cacheStream.pause()
if (err.code === 'EINTEGRITY')
await cacache.rm.content(this.options.cachePath, this.entry.integrity, { memoize: this.options.memoize })
if (err.code === 'ENOENT' || err.code === 'EINTEGRITY')
await CacheEntry.invalidate(this.request, this.options)
body.emit('error', err)
cacheStream.resume()
})
cacheStream.pipe(body)

@@ -375,3 +397,3 @@ }

response.headers.set('x-local-cache-status', status)
response.headers.set('x-local-cache-time', new Date(this.entry.time).toUTCString())
response.headers.set('x-local-cache-time', new Date(this.entry.metadata.time).toUTCString())
return response

@@ -378,0 +400,0 @@ }

2

lib/cache/policy.js

@@ -70,3 +70,3 @@ const CacheSemantics = require('http-cache-semantics')

// cache entry is likely to always identify itself as stale
this.policy._responseTime = this.entry.time
this.policy._responseTime = this.entry.metadata.time
}

@@ -73,0 +73,0 @@ }

@@ -17,2 +17,3 @@ const Minipass = require('minipass')

'ETIMEDOUT', // someone in the transaction is WAY TOO SLOW
'ERR_SOCKET_TIMEOUT', // same as above, but this one comes from agentkeepalive
// Known codes we do NOT retry on:

@@ -19,0 +20,0 @@ // ENOTFOUND (getaddrinfo failure. Either bad hostname, or offline)

{
"name": "make-fetch-happen",
"version": "9.0.3",
"version": "9.0.4",
"description": "Opinionated, caching, retrying fetch client",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc