New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port not available on Heroku during deploy #340

Closed
mhuggins opened this Issue Sep 6, 2017 · 3 comments

Comments

2 participants
@mhuggins

mhuggins commented Sep 6, 2017

I am deploying to Heroku, and I included the following scripts in my package.json:

"scripts": {
  "heroku-postbuild": "yarn run build"
  "start": "NODE_ENV=production node build/server.js"
}

Unfortunately, the PORT env var is not known at build time and is instead assigned by Heroku at run time, and since razzle needs to know the port at build time, it means I must build before starting the server. With that in mind, I tried changing my scripts to look like the following:

"scripts": {
  "start": "NODE_ENV=production yarn run build && node build/server.js"
}

Unfortunately, that takes too long and ends up binding after the 60 second Heroku timeout:

2017-09-06T01:23:13.536789+00:00 app[web.1]: Compiling client...
2017-09-06T01:23:14.395857+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-09-06T01:23:14.395963+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-09-06T01:23:14.499913+00:00 heroku[web.1]: Process exited with status 137
2017-09-06T01:23:14.509625+00:00 heroku[web.1]: State changed from starting to crashed

Is there a way that we could not require the port at build time? Why is it needed then anyway?

@xouabita

This comment has been minimized.

Show comment
Hide comment
@xouabita

xouabita Sep 6, 2017

Contributor

You can use razzle-heroku :) It extends the default razzle config to make it works on heroku.

Contributor

xouabita commented Sep 6, 2017

You can use razzle-heroku :) It extends the default razzle config to make it works on heroku.

@mhuggins

This comment has been minimized.

Show comment
Hide comment
@mhuggins

mhuggins Sep 6, 2017

Ahh, didn't know about that, thanks for pointing it out! If I already have razzle.config.js with a custom modify function, is there a way I can still use that while also making use of razzle-heroku?

mhuggins commented Sep 6, 2017

Ahh, didn't know about that, thanks for pointing it out! If I already have razzle.config.js with a custom modify function, is there a way I can still use that while also making use of razzle-heroku?

@xouabita

This comment has been minimized.

Show comment
Hide comment
@xouabita

xouabita Sep 6, 2017

Contributor
// razzle.config.js
const razzleHeroku = require("razzle-heroku")

module.exports = {
  modify: (config, {target, dev}, webpack) => {
    config = razzleHeroku(config, {target, dev}, webpack)
    // do something to config

    return config
  },
}

Maybe something like this ?

Contributor

xouabita commented Sep 6, 2017

// razzle.config.js
const razzleHeroku = require("razzle-heroku")

module.exports = {
  modify: (config, {target, dev}, webpack) => {
    config = razzleHeroku(config, {target, dev}, webpack)
    // do something to config

    return config
  },
}

Maybe something like this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment