-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix sync issue #2233
fix sync issue #2233
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code seems fine but i'm a bit worried with ghost sync, let's talk about this quickly
const botId = parts[parts.indexOf('actions') - 1] | ||
|
||
// Debouncing invalidate since we get a lot of events when it happens | ||
private _invalidateRequire() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that I care about this change to be made but what about :
private _invalidateRequire = _.debounce(() => {
// code goes here
})
// and get rid of the constructor initialization for the func
@@ -17,7 +17,7 @@ import { VmRunner } from '../action/vm' | |||
import { Incident } from '../alerting-service' | |||
|
|||
const debug = DEBUG('hooks') | |||
const SYNC_DEBOUNCE_DELAY = ms('2s') | |||
const DEBOUNCE_DELAY = ms('2s') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know its not part of this PR but it seems to me that the code here and in action service is pretty much duplicated
@@ -215,6 +238,10 @@ export class ScopedGhostService { | |||
await this.primaryDriver.upsertFile(fileName, content, recordRevision) | |||
this.events.emit('changed', fileName) | |||
await this._invalidateFile(fileName) | |||
|
|||
if (syncDbToDisk) { | |||
await this.cache.sync(JSON.stringify({ rootFolder, botId: this.botId })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not leave the responsibility of serializing the obj do the sync method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to keep the logic in redis cache minimal
When actions are edited using the code-editor and a database, we need to sync them back to the file system so they can be required() by actions and hooks. VM2 can't load them from the ghost.
This PR fixes an issue where there was way too many invalidate triggered for nothing. It is triggered once when a file is inserted, then it is propagated to other nodes via redis