Repository navigation
T-010: fix: respect HOST when selecting port - #126
Merged
Merged
Conversation
getPort() now resolves PORT and HOST separately, each from process.env first and then from the dot-env files in their order of priority. The port is checked on HOST in each case, including the default port 3333. Closes #115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #124 by @joniilmanfahmi00-collab
Closes #115
Goal
getPort()of@adonisjs/assembler, which the dev server andnode ace testuse, checks if the port is free on the host where the app will listen.The pull request #124 passes
HOSTonly from the place where it foundPORT. The app readsHOSTfromprocess.envfirst and then from the.envfiles. This pull request makesgetPort()readHOSTthe same way, apart from wherePORTcomes from. The commit of the contributor stays.Deployment requirements
@adonisjs/assembleras a patch.Acceptance criteria
All tests are in
tests/utils/get_port.spec.ts.npm run lint,npm run typecheckandnpm run quick:test(305 tests) pass.getPort()resolvesHOSTfromprocess.envfirst, then from the.envfiles, in the order the app reads them, and passes it toget-port.give preference to HOST from process.env over .env file,give preference to HOST from .env.local file over .env file. Pass.PORTfromprocess.env,PORTfrom a.envfile, and the default port 3333.pass HOST from process.env to get-port,pass HOST from .env file to get-port,pass HOST to get-port when using the default port 3333. Pass.HOSTinprocess.envandPORTin.env, and the reverse, the port is checked on thatHOST.pass HOST from process.env when PORT comes from .env file,pass HOST from .env file when PORT comes from process.env. Pass.HOSTis not set anywhere,get-portgets no host, as today.check the port on all the local hosts when HOST is not set. Pass.Four of the new tests fail on the code of #124: the default port 3333,
HOSTandPORTfrom different places, and.env.localover.env.Decisions about the code
getPort()now loads and parses each.envfile each time, also whenprocess.env.PORTis set.HOSTcan be in a.envfile whenPORTis not.HOSTcounts as not set, the same way an emptyPORTdoes today.getPort()passes nohostkey toget-portwhenHOSTis not set, soget-portkeeps its check on each local host.clearLockedPorts()ofget-portbefore each test, becauseget-portlocks each port that it gives for 15 seconds.Context changes
None.
Discovered work
TestRunner.runAndWatch()insrc/test_runner.tssets#stickyHmrPortwithString(getRandomPort({ port: 24678 }))and noawait. The value is[object Promise].TestRunner.run()has theawait.