Skip to content

Commit b07a59e

Browse files
author
Patrick Mueller
committed
handle ports race condition by returning 3000
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.
1 parent 6927628 commit b07a59e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
tmp
33
npm-debug.log
4+
.vscode

lib-src/cfenv.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ getPort = (appEnv) ->
174174
unless portString?
175175
return 3000 unless appEnv.name?
176176

177-
portString = "#{ports.getPort appEnv.name}"
177+
try
178+
portString = "#{ports.getPort appEnv.name}"
179+
catch e
180+
portString = '3000'
178181

179182
port = parseInt portString, 10
180183
throwError "invalid PORT value: /#{portString}/" if isNaN port

lib/cfenv.js

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)