Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed `Runner::run()` — `mkdir()` return value now checked to prevent silent failures ([#151](https://github.com/crazy-goat/workerman-bundle/issues/151))
- Throws `\RuntimeException` with clear message when directory creation fails
- Double `is_dir()` check handles race condition between check and `mkdir()` call

## [0.14.0] - 2026-04-14

### Deprecated
Expand Down
4 changes: 2 additions & 2 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function run(): int
assert(is_int($stopTimeout));
assert(is_int($maxPackageSize));

if (!is_dir($varRunDir = dirname($pidFile))) {
mkdir(directory: $varRunDir, recursive: true);
if (!is_dir($varRunDir = dirname($pidFile)) && !mkdir(directory: $varRunDir, recursive: true) && !is_dir($varRunDir)) {
throw new \RuntimeException(\sprintf('Unable to create directory "%s".', $varRunDir));
}

TcpConnection::$defaultMaxPackageSize = $maxPackageSize;
Expand Down
6 changes: 6 additions & 0 deletions tests/RunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public function testRunnerUsesCorrectForkErrorHandling(): void
$content,
'Must have CACHE_WARMUP_TIMEOUT constant',
);

$this->assertStringContainsString(
'Unable to create directory',
$content,
'Must throw when mkdir() fails to create var/run directory',
);
}

/**
Expand Down