Skip to content

Dev server is closed with code 1 on SIGTERM #6140

@kirill-konshin

Description

@kirill-konshin

Bug report

This is a bug report + a workaround that can help someone who will experience same issue like me.

Describe the bug

https://github.com/zeit/next.js/blob/master/bin/next#L78

Dev server is closed with code 1 on SIGTERM. For example this breaks jest-puppeteer (which use jest-dev-server): it kills the server process after all tests are done.

To Reproduce

The following simple jest-puppeteer.config.js may be used:

module.exports = {
    server: {
        command: 'npm start',
        port: 3000,
        launchTimeout: 30000
    }
};

Expected behavior

Process should exit with 0 code on SIGTERM. Not sure why SIGTERM results in 1 error code, that's not an error, it's just a termination, so if it is successfully terminated 0 code is fine.

Workaround

Working workaround :) — put || exit 0 or || true in package.json:

{
  "scripts": {
    "start": "next || exit 0"
  }
}

Does not work:

module.exports = {
    server: {
        command: 'npm start || exit 0'
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions