New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@live-change/framework

Package Overview
Dependencies
Maintainers
1
Versions
368
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/framework - npm Package Compare versions

Comparing version 0.4.24 to 0.4.25

59

lib/utils/EventSourcing.js
const EventsReader = require('./EventsReader.js')
const ReactiveDao = require('@live-change/dao')
function sleep(ms) {
return new Promise((resolve, reject) => setTimeout(resolve, ms))
}
class EventSourcing {

@@ -73,24 +77,43 @@ constructor(connection, database, logName, consumerName, config = {}) {

}
if(this.config.filter && !this.config.filter(event)) return []
try {
let handled = false
let eventHandlers = this.eventTypeHandlers.get(event.type) || []
for(let handler of eventHandlers) {
const result = await handler(event, mainEvent)
if(result != 'ignored') handled = true
if (this.config.filter && !this.config.filter(event)) return []
let done = false
let retry = 0
const maxRetry = process.env.MAX_EVENT_RETRY_COUNT || 10
while(!done && maxRetry) {
try {
await this.doHandleEvent(event, mainEvent)
} catch(e) {
if(e == 'timeout' && retry < maxRetry) {
retry++
sleepTime = Math.pow(2, retry) * 100
console.error(`Event \n${JSON.stringify(event, null, " ")}\n handling timeout, will retry `,
retry, ' time after ', sleepTime, 'ms sleep')
sleep(retry)
} else {
console.error(`EVENT \n${JSON.stringify(event, null, " ")}\n HANDLING ERROR`, e, ' => STOPPING!')
this.dispose()
throw e
}
}
for(let handler of this.allEventHandlers) {
const result = await handler(event, mainEvent)
if(result != 'ignored') handled = true
}
if(!handled) {
throw new Error("notHandled")
}
} catch(e) {
console.error(`EVENT \n${JSON.stringify(event,null," ")}\n HANDLING ERROR`, e, ' => STOPPING!')
this.dispose()
throw e
}
return [event]
}
async doHandleEvent(event, mainEvent) {
let handled = false
let eventHandlers = this.eventTypeHandlers.get(event.type) || []
for (let handler of eventHandlers) {
const result = await handler(event, mainEvent)
if (result != 'ignored')
handled = true
}
for (let handler of this.allEventHandlers) {
const result = await handler(event, mainEvent)
if (result != 'ignored')
handled = true
}
if (!handled) {
throw new Error("notHandled")
}
}
async savePosition() {

@@ -97,0 +120,0 @@ if(this.lastSavedPosition == this.state.position) return

{
"name": "@live-change/framework",
"version": "0.4.24",
"version": "0.4.25",
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",

@@ -5,0 +5,0 @@ "main": "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