Skip to content

Conversation

@pavkam
Copy link
Contributor

@pavkam pavkam commented Feb 8, 2025

This PR Introduces flushOnExit option in batch buffer configuration. When on (default), the client will flush all events on it's exit.

- Introduce `flushOnExit` option in batch buffer configuration
- Add new `flusher.ts` module to handle graceful process exit and event flushing
- Update client initialization to conditionally register exit flush handler
- Enhance README with documentation about exit flushing behavior
- Add comprehensive test coverage for exit flushing mechanism
@pavkam pavkam self-assigned this Feb 8, 2025
- Add test to verify no exit flush handler when `offline` is true
- Add test to ensure no data is flushed when in offline mode
@roncohen
Copy link
Contributor

roncohen commented Feb 9, 2025

Got this error on the first try:

Screenshot 2025-02-09 at 16 58 56

@pavkam
Copy link
Contributor Author

pavkam commented Feb 9, 2025

Got this error on the first try:
Screenshot 2025-02-09 at 16 58 56

Yeah, me, trying to be smart, removed the anonymous function wrapper, and this has disappeared. Pushed a commit

Copy link
Contributor

@roncohen roncohen left a comment

Choose a reason for hiding this comment

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

looks good after the current comments have been resolved 👍

Introduces `withTimeout()` and `TimeoutError` to provide a robust way of adding timeouts to promises. The new utility allows wrapping promises with a configurable timeout, rejecting with a custom error if the promise doesn't resolve within the specified time.
Use the new `withTimeout()` utility to replace manual Promise.race() implementation in flusher, improving error handling and readability
- Remove manual host configuration in bucket example
- Add dotenv import in serve example to load environment variables
Update the exit code calculation in signal handling to use 0x80 instead of 0x100, ensuring consistent exit code behavior
@pavkam pavkam enabled auto-merge (squash) February 13, 2025 05:42
@pavkam pavkam merged commit 77d6c63 into main Feb 13, 2025
5 checks passed
@pavkam pavkam deleted the flush-on-terminate branch February 13, 2025 05:46
roncohen pushed a commit that referenced this pull request Feb 21, 2025
This PR Introduces `flushOnExit` option in batch buffer configuration.
When on (default), the client will flush all events on it's exit.
roncohen pushed a commit that referenced this pull request Feb 25, 2025
This PR Introduces `flushOnExit` option in batch buffer configuration.
When on (default), the client will flush all events on it's exit.
roncohen pushed a commit that referenced this pull request Feb 26, 2025
This PR Introduces `flushOnExit` option in batch buffer configuration.
When on (default), the client will flush all events on it's exit.
roncohen pushed a commit that referenced this pull request Feb 26, 2025
This PR Introduces `flushOnExit` option in batch buffer configuration.
When on (default), the client will flush all events on it's exit.
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