Skip to content

fix: await in sequence - #49

Merged
ai merged 2 commits into
logux:nextfrom
DecathectZero:tyler/await-in-sequence/CT-000
Aug 31, 2022
Merged

fix: await in sequence#49
ai merged 2 commits into
logux:nextfrom
DecathectZero:tyler/await-in-sequence/CT-000

Conversation

@DecathectZero

@DecathectZero DecathectZero commented Aug 30, 2022

Copy link
Copy Markdown
Contributor

It's critical that any list of messages coming in are added to the log in the right order.

We have channels/actions that write this incoming data into the database upon adding to the log.
It can potentially run out of order because we run lines 74-78:

core/sync/index.js

Lines 74 to 81 in 0a021be

return this.options
.inFilter(...filtered)
.then(res => {
return res ? filtered : false
})
.catch(e => {
this.error(e)
})

the inFilter is actually another promise, and on logux/server, it awaits processor.access:
https://github.com/logux/server/blob/63337798eea393fbeee1c6cb519bce3ae71ef354/server-client/index.js#L214

This means the this.log.add and subsequent processor.process could be out of order.

Comment thread sync/index.js Outdated
for (let i = 0; i < data.length - 1; i += 2) {
let action = data[i]
let meta = data[i + 1]
const action = data[i]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this change? It breaks CI since we use another code standard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, noted

@ai
ai changed the base branch from main to next August 31, 2022 07:55
@ai
ai merged commit 6bc1b6a into logux:next Aug 31, 2022
@ai

ai commented Aug 31, 2022

Copy link
Copy Markdown
Member

Good fix. I added Promise.all to make it faster by “parallel” processing, but I agree that it could create more problems.

We need to release it as major release. Do you need to release it quickly (or you found some hacky workaround)?

@DecathectZero

Copy link
Copy Markdown
Contributor Author

Good fix. I added Promise.all to make it faster by “parallel” processing, but I agree that it could create more problems.

We need to release it as major release. Do you need to release it quickly (or you found some hacky workaround)?

@ai a quicker release would be preferred, but appreciate whatever works best for you!

@ai

ai commented Sep 1, 2022

Copy link
Copy Markdown
Member

I will try to do the release on weekend

@ai

ai commented Sep 3, 2022

Copy link
Copy Markdown
Member

Done. I released Logux Core 0.8 (release name Ա in honor of Armenian alphabet) and major versions of Logux Server and Logux Client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants