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

json-rpc-engine

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-engine - npm Package Compare versions

Comparing version 3.6.1 to 3.6.2

2

package.json
{
"name": "json-rpc-engine",
"version": "3.6.1",
"version": "3.6.2",
"description": "a tool for processing JSON RPC",

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

@@ -8,9 +8,13 @@ const promiseToCallback = require('promise-to-callback')

return (req, res, next, end) => {
let nextHandlerOnDone = null
let nextDonePromise = null
const finishedPromise = asyncMiddleware(req, res, getNextPromise)
promiseToCallback(finishedPromise)((err) => {
// async middleware ended
if (nextHandlerOnDone) {
if (nextDonePromise) {
console.log('detected next was called')
// next handler was called - complete nextHandler
nextHandlerOnDone(err)
promiseToCallback(nextDonePromise)((nextErr, nextHandlerSignalDone) => {
if (nextErr) return done(nextErr)
nextHandlerSignalDone(err)
})
} else {

@@ -22,11 +26,14 @@ // next handler was not called - complete middleware

function getNextPromise() {
async function getNextPromise() {
nextDonePromise = getNextDoneCallback()
await nextDonePromise
return undefined
}
function getNextDoneCallback() {
return new Promise((resolve) => {
next((cb) => {
nextHandlerOnDone = cb
resolve()
})
next((cb) => resolve(cb))
})
}
}
}
}

@@ -93,2 +93,22 @@ /* eslint-env mocha */

})
it('doesnt await next', function (done) {
let engine = new RpcEngine()
engine.push(createAsyncMiddleware(async (req, res, next) => {
next()
}))
engine.push(function (req, res, next, end) {
res.result = 1234
end()
})
let payload = { id: 1, jsonrpc: '2.0', method: 'hello' }
engine.handle(payload, function (err, res) {
assert.ifError(err, 'has err')
done()
})
})
})
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