dashcam 1.4.13-beta.1 → 1.4.13-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/dashcam.js CHANGED
@@ -6,6 +6,7 @@ import { logger, setVerbose } from '../lib/logger.js';
6
6
  import { APP } from '../lib/config.js';
7
7
  import { createPattern } from '../lib/tracking.js';
8
8
  import { processManager } from '../lib/processManager.js';
9
+ import { cleanupSystemInfo } from '../lib/systemInfo.js';
9
10
  import { fileURLToPath } from 'url';
10
11
  import { dirname } from 'path';
11
12
  import path from 'path';
@@ -39,6 +40,9 @@ async function gracefulShutdown(signal) {
39
40
  logger.info('Received shutdown signal, cleaning up...', { signal });
40
41
 
41
42
  try {
43
+ // Clean up systeminformation child processes first to prevent stack overflow
44
+ cleanupSystemInfo();
45
+
42
46
  // Check if there's an active recording and stop it
43
47
  if (processManager.isRecordingActive()) {
44
48
  logger.info('Stopping active recording before exit...');
@@ -456,8 +460,6 @@ program
456
460
  .description('Stop the current recording and wait for upload completion')
457
461
  .action(async () => {
458
462
 
459
- console.log('!!!! Updated Stop')
460
-
461
463
  try {
462
464
  // Enable verbose logging for stop command
463
465
  setVerbose(true);
package/lib/recorder.js CHANGED
@@ -469,10 +469,10 @@ export async function startRecording({
469
469
  });
470
470
 
471
471
  if (currentRecording.all) {
472
- currentRecording.all.setEncoding('utf8');
473
472
  currentRecording.all.on('data', (data) => {
474
473
  // Parse FFmpeg output for useful information
475
- const output = data.toString().trim();
474
+ // Handle potentially invalid UTF-8 sequences by replacing them
475
+ const output = data.toString('utf8').replace(/\uFFFD/g, '').trim();
476
476
  logger.info(`FFmpeg output: ${output}`);
477
477
 
478
478
  // Check for actual permission issues (not fallback messages)
package/lib/systemInfo.js CHANGED
@@ -1,6 +1,23 @@
1
1
  import si from 'systeminformation';
2
2
  import { logger } from './logger.js';
3
3
 
4
+ /**
5
+ * Cleanup systeminformation child processes to prevent stack overflow on exit
6
+ */
7
+ export function cleanupSystemInfo() {
8
+ try {
9
+ logger.debug('Cleaning up systeminformation processes...');
10
+ // The systeminformation library keeps child processes running
11
+ // We need to clean them up to prevent stack overflow on Windows
12
+ if (si && typeof si.powerShellRelease === 'function') {
13
+ si.powerShellRelease();
14
+ }
15
+ logger.debug('Systeminformation cleanup complete');
16
+ } catch (error) {
17
+ logger.debug('Error cleaning up systeminformation', { error: error.message });
18
+ }
19
+ }
20
+
4
21
  /**
5
22
  * Collects comprehensive system information including CPU, memory, OS, and graphics data.
6
23
  * This matches the data format expected by the Dashcam backend (same as desktop app).
@@ -30,6 +47,10 @@ export async function getSystemInfo() {
30
47
  } catch (error) {
31
48
  logger.debug('Graphics info timed out, using empty graphics data');
32
49
  }
50
+
51
+ // Immediately cleanup PowerShell processes after collection to prevent race conditions
52
+ // This prevents the stack overflow issue if an error occurs later during upload
53
+ cleanupSystemInfo();
33
54
 
34
55
  const systemInfo = {
35
56
  cpu: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dashcam",
3
- "version": "1.4.13-beta.1",
3
+ "version": "1.4.13-beta.3",
4
4
  "description": "Minimal CLI version of Dashcam desktop app",
5
5
  "main": "bin/dashcam.js",
6
6
  "bin": {
Binary file
package/LINUX_PERF_FIX.md DELETED
@@ -1,184 +0,0 @@
1
- # Linux Performance Tracking Fixes
2
-
3
- ## Problem
4
- Performance data from dashcam-cli-minimal was not working on Ubuntu Linux.
5
-
6
- ## Root Causes Identified
7
-
8
- ### 1. **ps command compatibility**
9
- - Some Linux distributions (especially minimal/container images) use BusyBox `ps` which doesn't support the `--sort` option
10
- - The code was failing when trying to use `ps --sort=-pcpu`
11
-
12
- ### 2. **Missing error handling**
13
- - Insufficient logging made it hard to diagnose where the performance tracking was failing
14
- - No fallback mechanisms when certain system calls failed
15
-
16
- ### 3. **Network metrics parsing**
17
- - The macOS netstat parsing had an off-by-one error in the parts length check
18
- - Could cause network metrics to fail silently
19
-
20
- ### 4. **Import optimization**
21
- - The Linux network code was using `await import('fs')` dynamically when `fs` was already imported at the top
22
-
23
- ## Fixes Applied
24
-
25
- ### topProcesses.js
26
- 1. **Added fallback for ps --sort**:
27
- ```javascript
28
- try {
29
- // Try with --sort first
30
- const result = await execFileAsync('ps', ['-eo', 'pid,pcpu,pmem,comm', '--sort=-pcpu'], ...);
31
- } catch (sortError) {
32
- // Fallback to unsorted and sort in JavaScript
33
- const result = await execFileAsync('ps', ['-eo', 'pid,pcpu,pmem,comm'], ...);
34
- }
35
- ```
36
-
37
- 2. **Improved parsing with filtering**:
38
- - Now filters out invalid entries (pid <= 0)
39
- - Handles missing/undefined CPU and memory values
40
- - Always sorts by CPU in JavaScript as a backup
41
-
42
- 3. **Added timeouts**:
43
- - All process listings now have 5-10 second timeouts to prevent hanging
44
-
45
- ### performanceTracker.js
46
- 1. **Fixed network metrics**:
47
- - Corrected macOS netstat parsing (parts.length >= 10 instead of >= 7)
48
- - Removed redundant `await import('fs')` on Linux
49
- - Already using `fs` from the top-level import
50
-
51
- 2. **Enhanced error handling**:
52
- - All metric collection methods now have comprehensive try/catch blocks
53
- - Graceful degradation - if one metric fails, others continue
54
- - Better logging with platform and error context
55
-
56
- 3. **Improved logging**:
57
- - Added debug logs for successful operations
58
- - More detailed error messages including platform info
59
- - Stack traces for debugging
60
-
61
- ## Testing
62
-
63
- ### Quick Test (10 seconds)
64
- ```bash
65
- cd dashcam-cli-minimal
66
- node test-perf-linux.js
67
- ```
68
-
69
- This will:
70
- - Test `pidusage` library
71
- - Test `getTopProcesses` function
72
- - Test network metrics reading
73
- - Test system metrics
74
- - Run full performance tracker for 10 seconds
75
- - Show detailed results and identify any failures
76
-
77
- ### Full Recording Test
78
- ```bash
79
- # Start a recording with performance tracking
80
- dashcam start
81
-
82
- # Do some work for 10-15 seconds
83
- # ...
84
-
85
- # Stop recording
86
- dashcam stop
87
-
88
- # Check the output for performance data
89
- ```
90
-
91
- ### Expected Output
92
- The test should show:
93
- ```
94
- ✓ pidusage: PASS
95
- ✓ topProcesses: PASS
96
- ✓ networkMetrics: PASS
97
- ✓ systemMetrics: PASS
98
- ✓ performanceTracker: PASS
99
-
100
- Overall: ✓ ALL TESTS PASSED
101
- ```
102
-
103
- ## Platform-Specific Notes
104
-
105
- ### Ubuntu/Debian
106
- - Should work on all versions
107
- - Uses `/proc/net/dev` for network stats
108
- - Falls back if `ps --sort` not available
109
-
110
- ### Alpine Linux / Docker
111
- - BusyBox `ps` detected automatically
112
- - Sorts processes in JavaScript instead
113
- - May have limited network stats in containers
114
-
115
- ### CentOS/RHEL
116
- - Full GNU ps support
117
- - Should use `--sort` option
118
- - Full network stats available
119
-
120
- ## Troubleshooting
121
-
122
- ### If performance data is still empty:
123
-
124
- 1. **Check pidusage works**:
125
- ```bash
126
- node -e "import('pidusage').then(m => m.default(process.pid).then(console.log))"
127
- ```
128
-
129
- 2. **Check ps command**:
130
- ```bash
131
- ps -eo pid,pcpu,pmem,comm --sort=-pcpu | head -5
132
- # If this fails, try:
133
- ps -eo pid,pcpu,pmem,comm | head -5
134
- ```
135
-
136
- 3. **Check /proc/net/dev exists**:
137
- ```bash
138
- cat /proc/net/dev
139
- ```
140
-
141
- 4. **Run with verbose logging**:
142
- ```bash
143
- dashcam start --verbose
144
- # ... do work ...
145
- dashcam stop --verbose
146
- ```
147
-
148
- 5. **Check the performance file directly**:
149
- ```bash
150
- # Look for performance.jsonl in the output directory
151
- cat ~/.dashcam/recordings/*/performance.jsonl | head -1 | jq
152
- ```
153
-
154
- ## What Gets Tracked
155
-
156
- Even with the fixes, the following is tracked every 5 seconds:
157
-
158
- - ✅ Process CPU usage (dashcam process)
159
- - ✅ Process memory usage (dashcam process)
160
- - ✅ System-wide memory usage
161
- - ✅ System CPU core count
162
- - ✅ Top 10 processes by CPU
163
- - ✅ Network I/O (where available)
164
-
165
- ## API Upload
166
-
167
- The performance data is uploaded to the API with the recording:
168
-
169
- ```javascript
170
- {
171
- performance: {
172
- samples: [...], // Array of samples taken during recording
173
- summary: { // Aggregated statistics
174
- avgProcessCPU: 12.3,
175
- maxProcessCPU: 18.7,
176
- avgProcessMemoryMB: 128.0,
177
- maxProcessMemoryMB: 192.0,
178
- // ...
179
- }
180
- }
181
- }
182
- ```
183
-
184
- This data is then displayed in the web UI under the "Performance" tab.
@@ -1,225 +0,0 @@
1
- # Dashcam CLI - Log Tracking Guide
2
-
3
- The Dashcam CLI can track both **file-based logs** (from CLI applications) and **web browser logs** (from browser extensions). This guide explains how to use the log tracking features.
4
-
5
- ## File Log Tracking (CLI Applications)
6
-
7
- ### Adding Log Files to Track
8
-
9
- Track log files during recordings:
10
-
11
- ```bash
12
- # Add a single log file
13
- dashcam logs --add /var/log/myapp.log
14
-
15
- # Add multiple log files
16
- dashcam logs --add /tmp/debug.log
17
- dashcam logs --add ~/.npm/_logs/npm.log
18
- dashcam logs --add /var/log/nginx/access.log
19
- ```
20
-
21
- ### Removing Log Files
22
-
23
- ```bash
24
- # Remove a log file from tracking
25
- dashcam logs --remove /var/log/myapp.log
26
- ```
27
-
28
- ### Viewing Tracked Files
29
-
30
- ```bash
31
- # List all currently tracked log files
32
- dashcam logs --list
33
-
34
- # Show detailed tracking status
35
- dashcam logs --status
36
- ```
37
-
38
- ## Web Browser Log Tracking
39
-
40
- ### Setting Up Web App Tracking
41
-
42
- Web log tracking requires configuring patterns for URLs you want to monitor:
43
-
44
- ```bash
45
- # Create a config file for web apps (web-logs.json)
46
- cat > web-logs.json << 'EOF'
47
- [
48
- {
49
- "id": "my-web-app",
50
- "type": "web",
51
- "name": "My Web Application",
52
- "enabled": true,
53
- "patterns": [
54
- "*localhost:3000*",
55
- "*myapp.com*",
56
- "*staging.myapp.com*"
57
- ]
58
- },
59
- {
60
- "id": "github",
61
- "type": "web",
62
- "name": "GitHub",
63
- "enabled": true,
64
- "patterns": [
65
- "*github.com*"
66
- ]
67
- }
68
- ]
69
- EOF
70
- ```
71
-
72
- ### Updating Web Log Configuration
73
-
74
- ```javascript
75
- // In your Node.js script or through the API
76
- import { logsTrackerManager } from './lib/logs/index.js';
77
-
78
- const webConfig = [
79
- {
80
- id: 'my-app',
81
- type: 'web',
82
- name: 'My Application',
83
- enabled: true,
84
- patterns: ['*localhost:3000*', '*myapp.com*']
85
- }
86
- ];
87
-
88
- logsTrackerManager.updateLogsConfig(webConfig);
89
- ```
90
-
91
- ## Recording with Log Tracking
92
-
93
- ### Start a Recording with Logs
94
-
95
- ```bash
96
- # Start recording (logs are automatically included if configured)
97
- dashcam record --duration 30
98
-
99
- # The recording will include:
100
- # - All tracked log files (--add files above)
101
- # - Web browser events (if browser extension is installed)
102
- ```
103
-
104
- ### Browser Extension Setup
105
-
106
- 1. **Install the Dashcam browser extension** (Chrome/Firefox)
107
- 2. **The CLI automatically starts a WebSocket server** on ports: 10368, 16240, 21855, 24301, or 25928
108
- 3. **Extension connects automatically** when CLI is running
109
- 4. **Web events are captured** based on your URL patterns
110
-
111
- ## Log Event Types
112
-
113
- ### File Logs
114
- - **Line events**: Each new line written to tracked files
115
- - **Timestamps**: Precise timing for synchronization with video
116
- - **Error detection**: Automatic highlighting of error lines
117
-
118
- ### Web Logs
119
- - **Console logs**: `console.log()`, `console.error()`, etc.
120
- - **Network requests**: HTTP requests and responses
121
- - **Navigation events**: Page loads and URL changes
122
- - **Tab management**: Tab switches and window focus
123
-
124
- ## Example Workflow
125
-
126
- ```bash
127
- # 1. Add log files to track
128
- dashcam logs --add /var/log/myapp.log
129
- dashcam logs --add /tmp/debug.log
130
-
131
- # 2. Check status
132
- dashcam logs --status
133
- # Output:
134
- # Log tracking status:
135
- # Active recording instances: 0
136
- # Configured CLI log files: 2
137
- # Total recent events: 15
138
- # File tracker details:
139
- # /var/log/myapp.log: 8 events (last minute)
140
- # /tmp/debug.log: 7 events (last minute)
141
-
142
- # 3. Start recording
143
- dashcam record --duration 60
144
-
145
- # 4. During recording:
146
- # - CLI monitors all tracked log files in real-time
147
- # - Browser extension sends web events via WebSocket
148
- # - All events are timestamped and synchronized
149
-
150
- # 5. After recording:
151
- # - Logs are automatically trimmed to match video duration
152
- # - Events are saved in JSONL format alongside video
153
- # - Logs can be replayed in sync with video
154
- ```
155
-
156
- ## Advanced Configuration
157
-
158
- ### Custom WebSocket Port
159
-
160
- ```javascript
161
- // If you need to use specific ports
162
- import { server } from './lib/websocket/server.js';
163
- await server.start(); // Uses predefined port list
164
- ```
165
-
166
- ### Pattern Matching for Web Apps
167
-
168
- Patterns support wildcards:
169
- - `*example.com*` - Matches any URL containing "example.com"
170
- - `*localhost:3000*` - Matches local development server
171
- - `*github.com/myuser/*` - Matches specific GitHub paths
172
-
173
- ### Log File Requirements
174
-
175
- - **Files must exist** before adding to tracking
176
- - **Files must be readable** by the CLI process
177
- - **Real-time writes** are monitored (uses `tail` library)
178
- - **Log rotation** is automatically handled
179
-
180
- ## Troubleshooting
181
-
182
- ### Common Issues
183
-
184
- 1. **"Log file does not exist"**
185
- ```bash
186
- # Ensure file exists first
187
- touch /var/log/myapp.log
188
- dashcam logs --add /var/log/myapp.log
189
- ```
190
-
191
- 2. **"WebSocket connection failed"**
192
- - Check that browser extension is installed
193
- - Verify no firewall blocking local ports
194
- - Ensure CLI is running when opening browser
195
-
196
- 3. **"No events captured"**
197
- ```bash
198
- # Check if files are being written to
199
- tail -f /var/log/myapp.log
200
-
201
- # Verify tracking status
202
- dashcam logs --status
203
- ```
204
-
205
- ### Getting Help
206
-
207
- ```bash
208
- # Show all log tracking options
209
- dashcam logs --help
210
-
211
- # Show general CLI help
212
- dashcam --help
213
- ```
214
-
215
- ## Integration with Recordings
216
-
217
- When you create a recording, all configured logs are:
218
-
219
- 1. **Automatically included** in the recording
220
- 2. **Synchronized** with video timestamps
221
- 3. **Trimmed** to match video start/end times
222
- 4. **Saved** in JSON Lines format for replay
223
- 5. **Uploaded** along with video files
224
-
225
- The result is a complete recording with both visual and log context, making debugging and analysis much more effective.
@@ -1,104 +0,0 @@
1
- # NPM Publish & Version Sync Issues
2
-
3
- ## Problem
4
-
5
- The npm publish workflow was failing with:
6
- ```
7
- npm error 404 'dashcam@1.0.1-beta.17' is not in this registry.
8
- ```
9
-
10
- ## Root Cause
11
-
12
- **Version drift** between local git tags, package.json, and npm registry:
13
-
14
- - **NPM registry**: `1.0.1-beta.13` (latest successfully published)
15
- - **Local package.json**: `1.0.1-beta.16` (from failed publish attempts)
16
- - **Git tags**: Only up to `v1.0.1-beta.9`
17
-
18
- This happened because the workflow:
19
- 1. Bumped version in package.json
20
- 2. Created git tag
21
- 3. Tried to publish
22
- 4. **Publish failed** (possibly due to test failures or video encoding issues)
23
- 5. Git changes were not reverted, leaving version incremented
24
-
25
- ## Fixes Applied
26
-
27
- ### 1. Updated Publish Workflow
28
-
29
- **Before**: Version bump → Push → Publish (wrong order!)
30
-
31
- **After**:
32
- 1. Sync with npm registry version
33
- 2. Bump version
34
- 3. **Publish first** ✅
35
- 4. Push only if publish succeeded ✅
36
-
37
- ```yaml
38
- - name: Bump version
39
- run: |
40
- # Get current version from npm
41
- CURRENT_NPM_VERSION=$(npm view dashcam dist-tags.beta)
42
-
43
- # Sync before bumping
44
- npm version $CURRENT_NPM_VERSION --no-git-tag-version --allow-same-version
45
-
46
- # Bump to next
47
- npm version prerelease --preid=beta
48
-
49
- - name: Publish to npm
50
- run: npm publish --access public --tag beta
51
-
52
- - name: Push changes # Only runs if publish succeeded
53
- run: git push --follow-tags
54
- ```
55
-
56
- ### 2. Created Version Sync Script
57
-
58
- `scripts/sync-version.sh` - Helps detect and fix version drift:
59
-
60
- ```bash
61
- ./scripts/sync-version.sh
62
- ```
63
-
64
- This will:
65
- - Compare local version with npm registry
66
- - Offer to sync package.json
67
- - Show unpublished git tags that need cleanup
68
-
69
- ### 3. Synced package.json
70
-
71
- Reset from `1.0.1-beta.16` → `1.0.1-beta.13` (current npm version)
72
-
73
- ## Video Issue Connection
74
-
75
- The failed publishes were likely caused by **test failures due to the video encoding bugs** we fixed:
76
-
77
- - Frame rate conflicts
78
- - Buffer size issues
79
- - Frame dropping
80
- - Incomplete container metadata
81
-
82
- All of these are now fixed in the recorder.js, so future CI runs should succeed.
83
-
84
- ## Next Steps
85
-
86
- 1. ✅ Package.json is synced
87
- 2. ✅ Workflow is fixed
88
- 3. ⚠️ Need to clean up unpublished git tags manually (optional):
89
-
90
- ```bash
91
- # List tags
92
- git tag | grep beta
93
-
94
- # Delete local tags for unpublished versions (14-16)
95
- git tag -d v1.0.1-beta.14 v1.0.1-beta.15 v1.0.1-beta.16
96
-
97
- # If they exist on remote, delete them
98
- git push origin :refs/tags/v1.0.1-beta.14
99
- git push origin :refs/tags/v1.0.1-beta.15
100
- git push origin :refs/tags/v1.0.1-beta.16
101
- ```
102
-
103
- 4. Push the fixes to trigger a new publish
104
- 5. Next version will be `1.0.1-beta.14` ✅