Skip to content

Close http server in cleanup #53661

@Meemaw

Description

@Meemaw

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000
    Binaries:
      Node: 20.3.1
      npm: 9.6.7
      Yarn: 1.22.18
      pnpm: 7.29.3
    Relevant Packages:
      next: 13.4.13-canary.18
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

Standalone mode (output: "standalone")

Link to the code that reproduces this issue or a replay of the bug

https://github.com/Meemaw/next-server-shutdown-reproducer

To Reproduce

  1. yarn build
  2. yarn start
  3. Visit http://localhost:3000
  4. Close the server before the page renders
  5. Get a "This site can’t be reached" error

Describe the Bug

NextJS doesn't gracefully handle inflight HTTP server connections. There is a cleanup code

, but it doesn't call server.cleanup().

There also seems to be a teardown function defined

async function teardown() {
)

, which does the correct thing, but is never called?

Expected Behavior

server.cleanup() should be called & awaited so any inflight requests are gracefully handled.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1961

Metadata

Metadata

Assignees

No one assigned

    Labels

    OutputRelated to the the output configuration option.bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions