Skip to content
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

Add compaction.failed event #52

Closed
wants to merge 1 commit into from
Closed

Conversation

tex0l
Copy link

@tex0l tex0l commented Jan 10, 2024

No description provided.

@tex0l tex0l requested a review from arantes555 January 10, 2024 16:04
@tex0l tex0l marked this pull request as ready for review January 10, 2024 16:14
Copy link

@arantes555 arantes555 left a comment

Choose a reason for hiding this comment

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

Just one minor, optional, suggestion. You can go ahead and merge if you decide not to implement my suggestion.

})
const error = await failure
if (!error || !(error instanceof Error) || error.message !== 'synthetic error') throw error
d.persistence.afterSerialization = afterSerializationOriginal

Choose a reason for hiding this comment

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

To make sure that this cleanup is always performed, it would be better to have this line in a finallly block.

Copy link
Author

Choose a reason for hiding this comment

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

Test are independant, there is a beforeEach that resets everything, the final line is actually useless, I suggest to remove it rather than put it in a finally block.

@tex0l
Copy link
Author

tex0l commented Jan 11, 2024

Actually, as it has now been decided (for a better browser support) to remove imports of native node modules, including node:events for EventEmitter.

An option could be to shim EventEmitter with a package or the browser's EventTarget, but nedb is not very event-oriented, it is not worth it.

Therefore, the compaction.done event will be replaced with an onCompaction: (err?: Error|null) => void callback, which can be used by users to shim a 'compaction.done' naively, which will provide an error if any is thrown during compaction.

@tex0l tex0l closed this Jan 11, 2024
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