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

undici-thread-interceptor

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undici-thread-interceptor - npm Package Compare versions

Comparing version 0.10.2 to 0.10.3

2

index.js

@@ -134,2 +134,4 @@ 'use strict'

handler.onResponseEnd(controller, [])
hooks.fireOnClientResponseEnd(newOpts, res, clientCtx)
}))

@@ -136,0 +138,0 @@

@@ -9,2 +9,3 @@ 'use strict'

'onClientResponse',
'onClientResponseEnd',
'onClientError'

@@ -21,2 +22,3 @@ ]

onClientResponse = noop
onClientResponseEnd = noop
onClientError = noop

@@ -60,2 +62,6 @@

fireOnClientResponseEnd (req, res, ctx) {
return this.onClientResponseEnd(req, res, ctx)
}
fireOnClientError (req, res, ctx, error) {

@@ -62,0 +68,0 @@ return this.onClientError(req, res, ctx, error)

2

package.json
{
"name": "undici-thread-interceptor",
"version": "0.10.2",
"version": "0.10.3",
"description": "An Undici interceptor that routes requests over a worker thread",

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

@@ -163,2 +163,3 @@ # undici-thread-interceptor

- `onClientResponse(req, res, clientCtx)`
- `onClientResponseEnd(req, res, clientCtx)`
- `onClientError(req, res, clientCtx, error)`

@@ -165,0 +166,0 @@

@@ -22,4 +22,4 @@ 'use strict'

const { dataInRequest } = req
console.log('onServerReponse called:', dataInRequest)
console.log('onServerResponse called:', dataInRequest)
}
})

@@ -109,2 +109,24 @@ 'use strict'

test('hooks - onClientResponseEnd', async (t) => {
const worker = new Worker(join(__dirname, 'fixtures', 'worker1.js'))
t.after(() => worker.terminate())
let hookCalled = null
const interceptor = createThreadInterceptor({
domain: '.local',
onClientResponseEnd: (_req, res) => {
hookCalled = Buffer.from(res.rawPayload).toString()
}
})
interceptor.route('myserver', worker)
const agent = new Agent().compose(interceptor)
const { statusCode } = await request('http://myserver.local', {
dispatcher: agent,
})
strictEqual(statusCode, 200)
deepStrictEqual(hookCalled, '{"hello":"world"}')
})
test('hooks - onClientError', async (t) => {

@@ -230,3 +252,3 @@ const worker = new Worker(join(__dirname, 'fixtures', 'error.js'))

await sleep(300)
deepStrictEqual(lines, ['onServerRequest called {"method":"GET","url":"/","headers":{"host":"myserver.local"}}', 'onServerReponse called: propagated'])
deepStrictEqual(lines, ['onServerRequest called {"method":"GET","url":"/","headers":{"host":"myserver.local"}}', 'onServerResponse called: propagated'])
})

@@ -233,0 +255,0 @@

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