Skip to content

Commit

Permalink
handle ports race condition by returning 3000
Browse files Browse the repository at this point in the history
fixes #40

This is a very simple to fix to the problem with ports where it
will occaisonally throw an error:

- hoodiehq-archive/node-ports#4

The fix is to catch the error and use port 3000.  Not great, but should
handle some cases where this was a problem.

An alternate fix to try would be to try fetching the port again, probably
in a loop (with some limit), in hopes of getting a value from ports.
  • Loading branch information
Patrick Mueller committed Mar 26, 2019
1 parent 6927628 commit b07a59e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
tmp
npm-debug.log
.vscode
5 changes: 4 additions & 1 deletion lib-src/cfenv.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ getPort = (appEnv) ->
unless portString?
return 3000 unless appEnv.name?

portString = "#{ports.getPort appEnv.name}"
try
portString = "#{ports.getPort appEnv.name}"
catch e
portString = '3000'

port = parseInt portString, 10
throwError "invalid PORT value: /#{portString}/" if isNaN port
Expand Down
9 changes: 7 additions & 2 deletions lib/cfenv.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b07a59e

Please sign in to comment.