You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A tiny, but consistently frustrating issue for me and many many devs out there is that the PORT env var is shared for a lot of things. If you have a classic split rails backend and react frontend, you can't reasonably easily start them by script. There are ugly and fragile options. When running things manually, its a minor annoyance, I have to wait to start the backend, then come back and run the react scripts start command to manually tell it "yeah, sure just use damn port 3001, that's fine!".
Most recently, this was a hassle for me when setting up proper end-to-end tests for co2trackers with cypress. I have to hardcode things, and its still fragile as hell.
if (ALTERNATE_REQUESTED_PORT !== undefined) {
console.log(`Found CRA_SPECIFIC_START_PORT: ${ALTERNATE_REQUESTED_PORT}. using...`);
return choosePort(HOST, ALTERNATE_REQUESTED_PORT);
}
// We attempt to use the default port but if it is busy, we offer the user to
// run on a different port. `choosePort()` Promise resolves to the next free port.
return choosePort(HOST, DEFAULT_PORT);
Describe alternatives you've considered
Alternatively, cra could use a command line param. Personally, I tend to prefer command line params over env vars because env vars are the ultimate global variable. They tend to lead to problems exactly like this 😆. I do understand the necessity - the comment about cloud9 suggests this is a reasonable design and I'm not suggesting you change it - otherwise tools have to do odd things like interposing processes. I remember back in the days when I tried to get into static analysis, the clang analyzer had to do some ugly things to interpose and build databases of all the commands executed.
Personally, my programming style is a ton more verbose than this codebase. If it were up to me, I'd also add a few lines to check if CRA_SPECIFIC_START_PORT exists, but doesn't seem like an integer, and print a nice warning. I find that going to the extra effort to validate these unlikely cases ends up saving me untold hours down the line when the unlikely inevitably happens.
Yes, I'm the kind of person who checks the return value of printf and fclose. You'd be amazed what you find.
Additional context
I dunno what else to say. This is a small annoyance that affects probably millions of people. Plenty of issues have been filed for it. It's been bugging me for a while and I'm finally getting around to fixing it instead of doing the actual important work I have to do trying to fight the ongoing pandemic 😉🤣. If every programmer in the world fixed at least one of the small little things that bugged them, the whole world would be a better place!
The text was updated successfully, but these errors were encountered:
Is your proposal related to a problem?
A tiny, but consistently frustrating issue for me and many many devs out there is that the
PORT
env var is shared for a lot of things. If you have a classic split rails backend and react frontend, you can't reasonably easily start them by script. There are ugly and fragile options. When running things manually, its a minor annoyance, I have to wait to start the backend, then come back and run the react scripts start command to manually tell it "yeah, sure just use damn port 3001, that's fine!".Most recently, this was a hassle for me when setting up proper end-to-end tests for co2trackers with cypress. I have to hardcode things, and its still fragile as hell.
Describe the solution you'd like
There's a comment in the code about cloud9, so hopefully this doesn't interact poorly.
Add another line of code under the line for selecting
DEFAULT_PORT
like so:...then later:
Describe alternatives you've considered
Alternatively, cra could use a command line param. Personally, I tend to prefer command line params over env vars because env vars are the ultimate global variable. They tend to lead to problems exactly like this 😆. I do understand the necessity - the comment about cloud9 suggests this is a reasonable design and I'm not suggesting you change it - otherwise tools have to do odd things like interposing processes. I remember back in the days when I tried to get into static analysis, the clang analyzer had to do some ugly things to interpose and build databases of all the commands executed.
Personally, my programming style is a ton more verbose than this codebase. If it were up to me, I'd also add a few lines to check if
CRA_SPECIFIC_START_PORT
exists, but doesn't seem like an integer, and print a nice warning. I find that going to the extra effort to validate these unlikely cases ends up saving me untold hours down the line when the unlikely inevitably happens.Yes, I'm the kind of person who checks the return value of
printf
andfclose
. You'd be amazed what you find.Additional context
I dunno what else to say. This is a small annoyance that affects probably millions of people. Plenty of issues have been filed for it. It's been bugging me for a while and I'm finally getting around to fixing it instead of doing the actual important work I have to do trying to fight the ongoing pandemic 😉🤣. If every programmer in the world fixed at least one of the small little things that bugged them, the whole world would be a better place!
The text was updated successfully, but these errors were encountered: