Skip to content

fix: make setup() in callBackPersistence async#106

Merged
robertsLando merged 2 commits intomoscajs:mainfrom
seriousme:async-setup
Jun 30, 2025
Merged

fix: make setup() in callBackPersistence async#106
robertsLando merged 2 commits intomoscajs:mainfrom
seriousme:async-setup

Conversation

@seriousme
Copy link
Copy Markdown
Contributor

while migrating aedes to async persistence I noticed that the setup() call in callback persistence did not return a promise.
This PR fixes that.

Kind regards,
Hans

@gnought
Copy link
Copy Markdown
Collaborator

gnought commented Jun 28, 2025

I’ve noticed several regressions. Should we review all tests to ensure better coverage?

@seriousme
Copy link
Copy Markdown
Contributor Author

I’ve noticed several regressions. Should we review all tests to ensure better coverage?

If we can improve the functionality then I'm all for it!
Do you have more info on the regressions you found?

Kind regards,
Hans

@robertsLando
Copy link
Copy Markdown
Member

I’ve noticed several regressions. Should we review all tests to ensure better coverage?

@gnought Could you be more specific? Of course in case of regressions we should add tests to cover this

Comment thread callBackPersistence.js Outdated
Comment on lines +34 to +36
setup (broker) {
return this.asyncPersistence.setup(broker)
}
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.

I'm wondering why our tests didn't catched this? Could you add one for this case?

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.

if you await setup() then it does not matter much to the calling function if the setup is async or not.
Only when you use .then() it matters. Aedes uses await , so to Aedes it does not matter. I only found it because aedes' test/will.js used setup() itself and was using .then.

Although it is technically speaking not a problem of setup() is not async I added the test to abstract.js so every persistence will be checked.

Kind regards,
Hans

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.

@robertsLando
Btw: The index.d.ts only covers the callback signatures where the asyncPersistence.d.ts covers the async signatures.
We could add the async behaviour to index.d.ts but since Aedes is the only consumer of this code I don't think it is worth the effort to do so.

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.

Nope no worries it's ok for now

@seriousme seriousme requested a review from robertsLando June 30, 2025 11:08
@robertsLando robertsLando merged commit 0cdf4e2 into moscajs:main Jun 30, 2025
6 checks passed
@seriousme seriousme deleted the async-setup branch June 30, 2025 14:08
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.

3 participants