Skip to content

Node v16.3.0 crash - Cannot read properties of null (reading 'statusCode') #4319

@richardlay

Description

@richardlay

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 16.3.0
  • module version with issue: 20.2.0
  • last module version without issue: 19.1.1
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information: Using AWS load balancer

What are you trying to achieve or the steps to reproduce?

When our AWS Load Balancer returns a HTTP 460 because the client closed the connection, the handling node application crashes with the following stack trace:

TypeError: Cannot read properties of null (reading 'statusCode')
at Request._finalize (/src/node_modules/@hapi/hapi/lib/request.js:500:31)
at Request._reply (/src/node_modules/@hapi/hapi/lib/request.js:437:18)
at Request._execute (/src/node_modules/@hapi/hapi/lib/request.js:282:14)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

This wasn't happening when we were using Hapi 19.1.1 with Node 14.

I've found some issues that appear similar:

This issue #4208, we're getting the error on the same line of code:

 if (this.response.statusCode === 500 &&

Also this comment #4225 (comment) suggests premature close events were fixed as of Hapi 20.1.2, so we're wondering if there is another edge case.

What was the result you got?

Node application crashes

What result did you expect?

The server to function normally and respond to requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportQuestions, discussions, and general support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions