Skip to content

[BUG] flagd process becomes zombie when ConnectService.startServer() fails #1807

@kanataxa

Description

@kanataxa

Observed behavior

When ConnectService.startServer() fails (e.g., due to port conflict), the flagd process does not terminate properly and becomes a zombie process. Additionally, no error logs are output, making it difficult to identify the root cause.

The issue occurs when the Shutdown() process executes before ConnectService.startMetricsServer() completes. In this case, s.metricsServer.ListenAndServe() runs after the Shutdown() process, leaving the process running indefinitely.

Expected Behavior

When ConnectService.startServer() fails, the flagd process expects to output error messages and process terminate.

Steps to reproduce

Start flagd with a port that's already in use.

FLAGD_PORT=8015 FLAGD_URI=file:./config/samples/example_flags.flagd.json flagd start

Interrupted(ctrl+c)

2025-10-08T21:10:39.110+0900	info	cmd/start.go:143	flagd version: dev (1ee636a), built at: 2025-10-08T21:10:13Z	{"component": "start"}
2025-10-08T21:10:39.110+0900	info	flag-sync/sync_service.go:98	starting flag sync service on port 8015	{"component": "FlagSyncService"}
2025-10-08T21:10:39.111+0900	info	file/filepath_sync.go:60	Starting filepath sync notifier	{"component": "sync", "sync": "fileinfo"}
2025-10-08T21:10:39.111+0900	info	ofrep/ofrep_service.go:58	ofrep service listening at 8016	{"component": "OFREPService"}
2025-10-08T21:10:39.111+0900	info	flag-evaluation/connect_service.go:251	metrics and probes listening at 8014	{"component": "service"}
2025-10-08T21:10:39.111+0900	info	file/filepath_sync.go:99	watching filepath: ./config/samples/example_flags.flagd.json	{"component": "sync", "sync": "fileinfo"}
^C2025-10-08T21:10:44.235+0900	info	flag-sync/sync_service.go:167	shutting down gRPC sync service	{"component": "FlagSyncService"}
2025-10-08T21:10:44.235+0900	info	ofrep/ofrep_service.go:69	shutting down ofrep service	{"component": "OFREPService"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageThis issue needs to be investigated by a maintainerbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions