Fix SSE stream discovery and add ESLint for WebUI

JavaScript fixes:
- Fix Invalid URL error in stream-discovery.js by adding window.location.origin as base URL
- Fix SSE race condition: ensure all stream_found events sent before complete event
- Comment unused eventType variable in stream-discovery.js
- Comment unused FrigateGenerator import in config-panel.js
- Fix quote style (double to single quotes)

Go fixes:
- Add sync.WaitGroup for result collector to prevent premature SSE closure
- Add logging for stream_found events
- Fix ERR_INCOMPLETE_CHUNKED_ENCODING by waiting for all streams to be sent

ESLint setup:
- Add ESLint v8.57.1 with .eslintrc.cjs config for ES2022 modules
- Add npm scripts for lint and lint:fix
- Update .gitignore for node_modules and package-lock.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
eduard256
2025-11-12 11:45:46 +03:00
parent 86a8fb36d5
commit d12d732671
7 changed files with 61 additions and 5 deletions
+8
View File
@@ -434,10 +434,15 @@ func (s *Scanner) testStreamsConcurrently(ctx context.Context, streams []models.
}()
// Start result collector
var collectorWg sync.WaitGroup
collectorWg.Add(1)
go func() {
defer collectorWg.Done()
for stream := range streamsChan {
result.Streams = append(result.Streams, stream)
s.logger.Info("sending stream_found event", "url", stream.URL, "type", stream.Type)
// Send to SSE
_ = streamWriter.SendJSON("stream_found", map[string]interface{}{
"stream": stream,
@@ -522,6 +527,9 @@ TestLoop:
wg.Wait()
close(streamsChan)
// Wait for result collector to finish processing all streams
collectorWg.Wait()
// Update final counts
result.TotalTested = int(atomic.LoadInt32(&tested))
result.TotalFound = int(atomic.LoadInt32(&found))