mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:40:46 +00:00
74b5affa75
## Description: Update from Express 4.22 > 5.2.1. And @types/express 4.17 > 5.0.6. ### CodeQL errors unjustified: Please dismiss the unjustified [CodeQL scanning results](https://github.com/openfrontio/OpenFrontIO/security/code-scanning?query=pr%3A3549+tool%3ACodeQL+is%3Aopen) for playground/server.ts: they were flagged for this PR but i didn't touch those specific parts of the file. More importantly: it is a test server, created by Mole/ @Aareksio. I made requests to dismiss the alerts but don't have the permissions to actually dismiss them myself Version 5 was the first major upgrade in 10 years when it was released in Sept 2024. 5.21 is from Dec 2025 so v5 teething problems should be over by now. Many of its dependencies also updated by some major versions. So it seems a worthy update but that is for you to decide. v4 will be EOL when v6 arrives, however that could be a year from now still maybe. - Migration: -- Updated package.json, ran `npm install "express@5"` and `npm install "@types/express@5.0.6"`. -- Used https://expressjs.com/en/guide/migrating-5.html -- Ran the codemods from the migration guide `npx codemod@latest @expressjs/v5-migration-recipe`. -- Checked manually. -- Checked again with help of Gemini 3.1 Pro based on same guide. -- Master.ts: use `*splat` instead of `*`, tested and going to non-existing URL lands back on index.html like it should. -- Worker.ts: MIME type _webp_ is now supported natively so remove added config. -- playground/server.ts: fix type error after upgrading types/express for `name` in `req.params`. And `app.listen` handles user provided callback on error, use that. The latter may not be not needed per se. -- While v5 does this now "When an error is thrown in an async function or a rejected promise is awaited inside an async function, those errors will be passed to the error handler as if calling next(err).", choose to leave our try/catch'es be. Since we use specific errors, probably easier for consistency in log searches and user reporting. - About performance: -- While [Express 5 seems a bit slower than 4](https://www.repoflow.io/blog/express-4-vs-express-5-benchmark-node-18-24), it is not by much especially on Node24 which we're on. Also there's a working group dedicated to improving Express performance, albeit they expect v6/7 to benefit from that more than v5 will. -- While there are faster alternatives in benchmarks, [in real-world usage Express still holds up as one of the best and even beats most 'faster' alternatives](https://medium.com/deno-the-complete-reference/node-js-the-fastest-web-framework-in-2025-static-file-server-case-1df462ad38cd). ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: tryout33
Pathfinding Tests
This directory contains benchmarking tools, scenario generators, and an interactive playground for testing and optimizing pathfinding algorithms in OpenFrontIO.
TLDR
npx tsx tests/pathfinding/benchmark/run.ts --synthetic --all
npx tsx tests/pathfinding/playground/server.ts
Directory Structure
tests/pathfinding/
├── benchmark.ts # Benchmarking tool
├── scenarios/ # Scenarios for benchmarks
│ ├── default.ts # Hand-picked scenario
│ └── synthetic/ # Auto-generated synthetic scenarios
└── playground/ # Interactive web-based visualization
Available algorithms
- NavSat - future implementation - NavigationSatellite (HPA*)
- PF.Mini - current implementation - PathFinder.Mini (A*)
Benchmarking
Running a Single Scenario
# Run default scenario with default adapter (NavSat)
npx tsx tests/pathfinding/benchmark/run.ts
# Run specific scenario
npx tsx tests/pathfinding/benchmark/run.ts default
# Run with specific adapter
npx tsx tests/pathfinding/benchmark/run.ts default legacy
Running Synthetic Scenarios
Synthetic scenarios are auto-generated from maps with random port selections and routes.
# Run single synthetic scenario
npx tsx tests/pathfinding/benchmark/run.ts --synthetic iceland
# Run single synthetic scenario with specific adapter
npx tsx tests/pathfinding/benchmark/run.ts --synthetic iceland legacy
# Run ALL synthetic scenarios (comprehensive benchmark)
npx tsx tests/pathfinding/benchmark/run.ts --synthetic --all
# Run all with specific adapter
npx tsx tests/pathfinding/benchmark/run.ts --synthetic --all legacy
Benchmark Metrics
The benchmark measures three key metrics:
- Initialization Time - How long it takes to preprocess the map
- Path Distance - Total distance across all routes (quality metric)
- Pathfinding Time - How long it takes to compute paths (performance metric)
Example Output
================================================================================
METRIC 1: INITIALIZATION TIME
================================================================================
Initialization time: 45.32ms
================================================================================
METRIC 2: PATH DISTANCE
================================================================================
Route Path Length
Miami → Boston 346 tiles
Miami → Houston 212 tiles
...
Total distance: 52432 tiles
Routes completed: 22 / 22
================================================================================
METRIC 3: PATHFINDING TIME
================================================================================
Route Time
Miami → Boston 2.45ms
Miami → Houston 1.82ms
...
Total time: 156.34ms
Average time: 7.11ms
Routes benchmarked: 22 / 22
================================================================================
SUMMARY
================================================================================
Adapter: default
Scenario: default
Scores:
Initialization: 45.32ms
Pathfinding: 156.34ms
Distance: 52432 tiles
Generating Scenarios
Generate Synthetic Scenarios
Synthetic scenarios are generated by:
- Finding all water shoreline tiles on a map
- Randomly selecting 200 ports
- Creating 1000 routes connecting nearby ports
# Generate scenario for a single map
npx tsx tests/pathfinding/benchmark/generate.ts iceland
# Generate scenarios for all maps
npx tsx tests/pathfinding/benchmark/generate.ts --all
# Force overwrite existing scenarios
npx tsx tests/pathfinding/benchmark/generate.ts iceland --force
npx tsx tests/pathfinding/benchmark/generate.ts --all --force
Interactive Playground
The playground provides a web-based UI for visualizing pathfinding results, comparing algorithms, and debugging.
Starting the Playground
# Start with path caching enabled (default)
npx tsx tests/pathfinding/playground/server.ts
# Start without path caching (to measure uncached performance)
npx tsx tests/pathfinding/playground/server.ts --no-cache
Then open http://localhost:5555 in your browser.