- Add prom-client ^15.1.3 as production dependency
- Migrate Counter class to use prom-client internally
- Migrate Gauge class to use prom-client internally
- Migrate Histogram class to use prom-client internally
- Update getMetricsOutput() to use prom-client's native metrics()
- Update contentType() to use prom-client's contentType
- Enable collectDefaultMetrics() for Node.js system metrics
- Maintain backward compatibility with existing API
Benefits:
- Native OpenMetrics format export
- Proper histogram bucket handling
- Default Node.js metrics (memory, CPU, event loop, GC)
- Better integration with Grafana/Prometheus ecosystem
* lid-mapping: get missing lid from usync
* lid-mapping, jid-utils: change to isPnUser and store multiple mappings
* process-message: parse protocolMsg mapping, and store from new msgs
* types: lid-mapping event, addressing enum, alt, contact, group types
* validate, decode: use lid for identity, better logic
* lid: final commit
* linting
* linting
* linting
* linting
* misc: fix testing and also remove version json
* lint: IDE fucking up lint
* lid-mapping: fix build error on NPM
* message-retry: fix proto import
* Add message retry manager for session recreation and caching
Introduces a MessageRetryManager to cache recent sent messages and manage automatic Signal session recreation for failed message retries. Adds new config options to enable these features, integrates retry manager into message send/receive logic, and provides periodic cache cleanup. Improves reliability of message delivery and retry handling.
* Add buffer timeout and cache limit to event-buffer
Introduces a buffer timeout to auto-flush events after 30 seconds and limits the history cache size to prevent memory bloat in event-buffer.ts.
* Add session validation to SignalRepository
Introduces a validateSession method to SignalRepository for checking session existence and state. Updates message retry logic to use the new validation, improving session recreation handling and retry management.
* Improve message retry management and tracking
Refactored message retry manager to use LRU caches for recent messages and session history, added retry counters and statistics tracking, and implemented phone request scheduling. Updated message receive and send logic to mark retry success and pass max retry count. Removed periodic cleanup logic in favor of cache TTLs for better resource management.
* lint fix
* Use validateSession for session checks in message send
Replaces direct session existence checks with the improved validateSession method, which also checks for session staleness. Adds debug logging for failed session validations to aid troubleshooting.
* Delete src/Utils/message-retry.ts
---------
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
* feat: implement state machine for chat synchronization and buffer management
* test: Add Jest configuration and tests for connection deadlock handling
- Created a Jest configuration file to set up testing environment.
- Implemented utility functions for creating isolated authentication sessions and mocking WebSocket connections.
- Added a test case to ensure that the connection does not deadlock when history sync is disabled, verifying the correct handling of message events.
* feat: add GitHub Actions workflow for running tests
* chore: sort import lint
* fix: implement timeout handling for AwaitingInitialSync state in chat socket, maybe fix memory leak
* feat: enhance chat synchronization by refining AwaitingInitialSync handling and adding history sync checks
**Fix Windows path issue in `build` script**
**Issue**
The `build` script in `package.json` was written as:
```json
"build": "tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig='tsconfig.build.json' --ext='.js'"
```
This works on Unix-based systems (macOS/Linux) but **breaks on Windows**, throwing an error:
```
Error: ENOENT: no such file or directory, open 'C:\path\to\project\'tsconfig.build.json''
```
> The single quotes `'` are treated **literally** on Windows CMD/PowerShell, resulting in a malformed path (e.g., `'tsconfig.build.json'` instead of `tsconfig.build.json`).
**Fixes**
Updated the script to remove single quotes around the `--tsconfig` and `--ext` arguments:
```json
"build": "tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig=tsconfig.build.json --ext=.js"
```
**Result**
```
PS C:\Users\Astro\Documents\GitHub\Baileys> npm run build
> baileys@6.7.18 build
> tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig=tsconfig.build.json --ext=.js
PS C:\Users\Astro\Documents\GitHub\Baileys>
```