Repository navigation
Description
Problem to Solve
The real port in use cannot be retrieved from the server instance. The one that is accessible today is taken from the constructor input, but if I set the port to 0, which means take any port that is available, the real port in use will be different. That port is today not accessible from the outside of the start method (that lives in the framework).
Proposal
Modify the server getter of port to return the real port, something like this:
Which would return the real port if available, otherwise the input port.
// server.dart
int get port => _ioServer?.port ?? _port;The ports would also need to be accessible from the test framework, as the server object is hidden in there. Perhaps this would warrant another test method? E.g. withRelic instead of withServerpod, for example.
Use Case
In the test framework, the port is set to 0 by default, which is a very good default, as that enables concurrent tests. But if I want to make network calls to any of the servers api, insights, web, I'm not able to do that as I cannot retrieve the port.
In my specific case I would like to make a network request to the webserver.
Alternatives
Hard-code the port, but then you lose the ability to run concurrently.
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
Are you interested in working on a PR for this?
- I want to work on this
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 🚀
Activity
christerswahn commentedon Sep 5, 2025
This should be already fixed in PR #3775 . Does it not work?
Isakdl commentedon Sep 5, 2025
You are right! But it is only for the web server! So in fact my bug report is slightly wrong, we get the real port for the web server, but not the others!