Repository navigation
v4.0.2: Improved Error Handling & Connection Reliability
This release introduces a comprehensive error handling system with typed errors and significantly improves connection reliability. The client now gracefully handles disconnections, provides clear error information, and ensures command queuing works properly during reconnection.
🔨 Breaking Changes
- Replaced
InvalidResponseErrorwith a more robustJackdErrorclass - Added
JackdErrorCodeenum with standardized error codes for all Beanstalkd responses - Errors now include:
code: Standardized error code (e.g.NOT_FOUND,BAD_FORMAT)message: Human-readable error descriptionresponse: Raw server response when available
✨ New Features
- Added socket keep-alive to prevent connection drops
- Improved connection reliability:
- Properly handles
close,end, anderrorsocket events - Rejects pending commands when connection is lost
- Cleans up internal state on disconnection
- Properly handles
- Added command timeout (10 seconds) to prevent hanging operations
- Commands can now be queued while disconnected and will execute upon reconnection
- Better handling of fatal connection errors
🐛 Bug Fixes
- Fixed socket memory leaks by properly cleaning up listeners
- Fixed command queue processing when reconnecting
- Improved error propagation from socket errors to command promises
- Properly rejects all pending commands on fatal errors
Migration Guide
Update error handling code to use the new JackdError class:
// Before
try {
await client.reserveJob(123);
} catch (err) {
if (err.message === "NOT_FOUND") {
// Handle not found
}
}
// After
try {
await client.reserveJob(123);
} catch (err) {
if (err instanceof JackdError && err.code === JackdErrorCode.NOT_FOUND) {
// Handle not found with strongly typed error
}
}Dependencies
- Updated esbuild from 0.24.2 to 0.25.0
Full Changelog: v3.4.3...v4.0.2