Skip to content

feat: Implement round-robin color assignment for workers instead of random unique assignment.#107

Open
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/logger-color-pool-infinite-loop
Open

feat: Implement round-robin color assignment for workers instead of random unique assignment.#107
codxbrexx wants to merge 1 commit intometacall:masterfrom
codxbrexx:fix/logger-color-pool-infinite-loop

Conversation

@codxbrexx
Copy link
Copy Markdown
Contributor

@codxbrexx codxbrexx commented Feb 26, 2026

Summary

Replaces the do...while random-search loop in src/utils/logger.ts with a simple round-robin index. Removes the now-unnecessary AssignedColorCodesType interface and assignedColorCodes map.

Related issue

Fixes #103
Part of tracking epic #99

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Chore / CI
  • Breaking change

How to test

  1. Checkout fix/logger-color-pool-infinite-loop
  2. Run npm ci
  3. Run npm start
  4. Deploy 17+ packages simultaneously and confirm the server keeps streaming logs without hanging

Checklist

  • I have read the contributing guidelines
  • I added tests that prove my fix is effective or that my feature works
  • I updated documentation if necessary

Notes for reviewers

One file changed — src/utils/logger.ts. The do...while loop that spun forever when all 16 ANSI color slots were taken is replaced with ANSICode[colorIndex % ANSICode.length]. Colors now cycle once all 16 are in use instead of locking the event loop. The assignedColorCodes tracking map and its interface are removed since they're no longer needed.

Release notes

Fixed a server hang triggered when logging output from 17 or more simultaneous deployments.

Notes for reviewers

The fix addresses a TODO regarding an endless loop hazard with a minimal algorithm change, verified by spawning 20 concurrent deployments without locking the event loop.

Release notes

Fixed a severe faas server hang triggered when logging output from 17 or more simultaneous deployments.

Test

image

Note for reviewers: The CI integration tests fixed on this PR will be fixed after #122 (CI fix — healthcheck, busboy race, protocol patch) is merged first. The logger change itself is isolated to src/utils/logger.ts and has no dependency on those fixes at the code level.

@codxbrexx codxbrexx force-pushed the fix/logger-color-pool-infinite-loop branch from c492ecf to a094f5c Compare February 28, 2026 16:56
@codxbrexx codxbrexx changed the title feat: Implement round-robin color assignment for workers instead of r… feat: Implement round-robin color assignment for workers instead of random unique assignment. Mar 1, 2026
@codxbrexx codxbrexx force-pushed the fix/logger-color-pool-infinite-loop branch from 9a8e39f to a094f5c Compare March 1, 2026 20:48
@codxbrexx
Copy link
Copy Markdown
Contributor Author

Need Help...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Logger Color Pool Infinite Loop Hangs Server at 17+ Concurrent Deployments.

1 participant