13 Commits

Author SHA1 Message Date
681d1cebb9 Detect and handle ControlSocket errors during SSH execution
**Motivations:**
- ControlSocket errors still occurring during command execution
- Socket can become invalid DURING execution of long commands
- Need to detect socket errors in command output and clean up immediately

**Root causes:**
- Socket validation before command execution cannot detect if socket dies during execution
- Long commands (npm install, build) can cause connection to die mid-execution
- Next command finds invalid socket and SSH disables multiplexing but leaves socket
- Previous cleanup only happened before execution, not after detecting errors

**Correctifs:**
- Capture SSH command output to detect 'ControlSocket already exists' errors
- If socket error detected, immediately cleanup and retry once
- This is a specific retry for socket errors only, not a general retry mechanism
- Ensures dead sockets are cleaned up even if they die during command execution

**Evolutions:**
- Better handling of socket invalidation during long-running commands
- Automatic recovery from socket errors detected during execution

**Pages affectées:**
- deploy.sh: Enhanced ssh_exec() to detect and handle socket errors in output
2026-01-06 14:40:31 +01:00
01110cd322 Fix root cause of ControlSocket already exists errors
**Motivations:**
- SSH errors 'ControlSocket already exists, disabling multiplexing' were occurring
- Socket could become invalid between check and execution
- ControlMaster=auto detects invalid socket but doesn't remove it, just disables multiplexing
- Dead socket remains and causes issues for subsequent commands

**Root causes:**
- ControlMaster socket can exist but connection can be dead
- Socket can become invalid between check_ssh_connection() and ssh_exec() execution
- ControlMaster=auto detects invalid socket but doesn't remove it, leaving dead socket
- Dead socket causes 'ControlSocket already exists' errors on subsequent commands
- Previous cleanup was not aggressive enough to remove dead sockets

**Correctifs:**
- Improved check_ssh_connection() to test actual connection with 'true' command instead of just 'ssh -O check'
- Enhanced cleanup_dead_ssh() to remove entire directory instead of just socket file
- This ensures socket is truly removed even if process is still holding it
- Removed complex multi-step cleanup, using simple directory removal and recreation
- Socket validation now tests actual connection usability, not just socket existence

**Evolutions:**
- More robust socket cleanup that guarantees removal of dead sockets
- Better detection of invalid sockets before command execution

**Pages affectées:**
- deploy.sh: Improved cleanup_dead_ssh() and check_ssh_connection() functions
2026-01-06 14:36:41 +01:00
a943ed62e2 Remove retry mechanism from SSH connections
**Motivations:**
- Retries are useless, connection must work on first attempt or fail
- Simplifying code by removing unnecessary retry logic
- Reducing complexity and potential for multiple connection attempts

**Root causes:**
- Retry mechanism was adding complexity without real benefit
- If SSH connection fails, retrying won't help, it should fail immediately

**Correctifs:**
- Removed all retry logic from ssh_exec() function
- Simplified to single attempt execution
- Kept socket validation and cleanup before execution
- Removed retry loop and counter variables

**Evolutions:**
- Simpler and more straightforward SSH connection handling
- Faster failure detection when connection issues occur

**Pages affectées:**
- deploy.sh: Simplified ssh_exec() function, removed retry mechanism
2026-01-06 14:32:17 +01:00
7cbb57f8c9 Reduce SSH connection attempts and improve socket cleanup
**Motivations:**
- Too many SSH connection attempts were being made during deployment
- ControlMaster socket cleanup was not aggressive enough
- Multiple SSH calls at step 5 created excessive connection attempts

**Root causes:**
- ControlMaster socket could remain but be invalid, causing SSH to disable multiplexing
- Each ssh_exec had up to 3 retries, and step 5 made 4-5 ssh_exec calls
- Socket cleanup was not forceful enough to remove invalid sockets
- Complex retry logic at step 5 created unnecessary SSH calls

**Correctifs:**
- Improved cleanup_dead_ssh() to forcefully remove socket and wait for proper closure
- Reduced max retries in ssh_exec from 3 to 2
- Simplified step 5 logic to reduce SSH calls from 4-5 to 2 (one check, one init if needed)
- Combined Git initialization commands into single SSH call to reduce connections
- Added sleep after socket cleanup to ensure proper closure

**Evolutions:**
- More efficient SSH connection management
- Reduced deployment time by minimizing connection attempts

**Pages affectées:**
- deploy.sh: Improved cleanup_dead_ssh(), reduced retries, simplified step 5 logic
2026-01-06 14:31:04 +01:00
ce63c08ac9 Fix deployment script blocking at Git repository check
**Motivations:**
- Deployment script was blocking at step 5 (Git repository verification)
- Command substitution with SSH could hang indefinitely
- Need to avoid blocking on SSH connection failures

**Root causes:**
- Command substitution \ with ssh_exec could block if SSH connection hangs
- Complex logic with grep on command output was fragile
- No proper timeout handling in the verification step

**Correctifs:**
- Simplified Git repository verification logic
- Removed command substitution that could block
- Use direct exit code checking instead of parsing output
- Improved error handling with explicit SSH exit code checking
- Added cleanup and retry mechanism for connection failures

**Evolutions:**
- More robust Git repository verification that doesn't block

**Pages affectées:**
- deploy.sh: Simplified Git repository verification step
2026-01-06 14:26:30 +01:00
a219d1ad42 lint fix wip2 2026-01-06 14:24:35 +01:00
8813498de4 Fix SSH connection errors during deployment
**Motivations:**
- SSH ControlMaster connection errors were causing deployment failures
- Connection reset errors were not handled properly
- No retry mechanism for failed SSH connections

**Root causes:**
- SSH ControlMaster socket could become stale or be closed prematurely
- No validation of connection before use
- No cleanup of dead connections
- Silent failures in conditional checks

**Correctifs:**
- Added connection validation before each SSH command
- Implemented automatic cleanup of dead SSH connections
- Added retry mechanism (up to 3 attempts) with connection cleanup
- Enhanced SSH options for better connection stability (ConnectTimeout, ServerAliveInterval, ServerAliveCountMax)
- Improved error handling in Git repository verification step with explicit error detection and recovery

**Evolutions:**
- Enhanced SSH connection management with robust error handling
- Better error messages to distinguish connection errors from other failures

**Pages affectées:**
- deploy.sh: Enhanced ssh_exec() function, added helper functions, improved error handling
- fixKnowledge/ssh-connection-errors-deployment.md: Documentation of the problem, root cause, and solution
2026-01-06 14:22:24 +01:00
42e3e7e692 Update all dependencies to latest versions and fix compatibility issues
**Motivations:**
- Keep dependencies up to date for security and features
- Automate dependency updates in deployment script
- Fix compatibility issues with major version updates (React 19, Next.js 16, nostr-tools 2.x)

**Root causes:**
- Dependencies were outdated
- Deployment script did not update dependencies before deploying
- Major version updates introduced breaking API changes

**Correctifs:**
- Updated all dependencies to latest versions using npm-check-updates
- Modified deploy.sh to run npm-check-updates before installing dependencies
- Fixed nostr-tools 2.x API changes (generatePrivateKey -> generateSecretKey, signEvent -> finalizeEvent, verifySignature -> verifyEvent)
- Fixed React 19 ref types to accept null
- Fixed JSX namespace issues (JSX.Element -> React.ReactElement)
- Added proper types for event callbacks
- Fixed SimplePool.sub typing issues with type assertions

**Evolutions:**
- Deployment script now automatically updates dependencies to latest versions before deploying
- All dependencies updated to latest versions (Next.js 14->16, React 18->19, nostr-tools 1->2, etc.)

**Pages affectées:**
- package.json
- deploy.sh
- lib/keyManagement.ts
- lib/nostr.ts
- lib/nostrRemoteSigner.ts
- lib/zapVerification.ts
- lib/platformTrackingEvents.ts
- lib/sponsoringTracking.ts
- lib/articlePublisherHelpersVerification.ts
- lib/contentDeliveryVerification.ts
- lib/paymentPollingZapReceipt.ts
- lib/nostrPrivateMessages.ts
- lib/nostrSubscription.ts
- lib/nostrZapVerification.ts
- lib/markdownRenderer.tsx
- components/AuthorFilter.tsx
- components/AuthorFilterButton.tsx
- components/UserArticlesList.tsx
- types/nostr-tools-extended.ts
2025-12-28 21:49:19 +01:00
87a7c682d7 Deploy: Use /tmp for SSH ControlPath to avoid spaces issue 2025-12-28 20:43:40 +01:00
30816f2d2d Deploy: Fix SSH ControlPath with spaces in home directory 2025-12-28 20:43:22 +01:00
6c3f38a411 Deploy: Use persistent SSH connection to avoid MaxStartups limit 2025-12-28 20:43:05 +01:00
88e6d41f26 Deploy: Remove connection button and replace with direct account creation/import 2025-12-28 20:42:38 +01:00
46d5f03fbe Remove connection button and replace with direct account creation/import options 2025-12-28 20:35:50 +01:00