[BUG] Attempted to assign to readonly property.

Open
#969 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
bun, javascript, node.js
Domain
backend, cli

Research direction

Reproduce the failure with bun install -g http-server, http-server -d false -i, and curl http://localhost:8080. Start with union/lib/response-stream.js at the _headerNames assignment and trace the request through union/lib/routing-stream.js and union/lib/core.js; done means the exception is handled and the host continues serving.

Written by the indexing model from the issue text.

Description

Environment Versions
  1. OS Type: Ubuntu 22.04.01 LTS
  2. Node version: node version unavailable. bun version 1.3.11
  3. http-server version: 14.1.1
Steps to reproduce
  1. bun install -g http-server
  2. http-server -d false -i
  3. curl http://localhost:8080
Expected result

Maybe 404? But at least capture the exception and keep serving the host.

Actual result
~# http-server -d false -i
Starting up http-server, serving ./

http-server version: 14.1.1

http-server settings: 
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: not visible
AutoIndex: not visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

<After curl the service>

48 | 
49 |   if (this.response) {
50 |     this._headers = this.response._headers = this.response._headers || {};
51 | 
52 |     // Patch to node core
53 |     this.response._headerNames = this.response._headerNames || {};
              ^
TypeError: Attempted to assign to readonly property.
      at <anonymous> (node:_http_outgoing:360:17)
      at new  (/root/.bun/install/global/node_modules/union/lib/response-stream.js:53:10)
      at new  (/root/.bun/install/global/node_modules/union/lib/routing-stream.js:30:17)
      at requestHandler (/root/.bun/install/global/node_modules/union/lib/core.js:27:25)
      at emit (node:events:98:22)
      at onNodeHTTPRequest (node:_http_server:367:22)
DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
 code: "DEP0066"

      at <anonymous> (internal:util/deprecate:9:30)
      at deprecated (internal:util/deprecate:20:29)
      at new  (/root/.bun/install/global/node_modules/union/lib/response-stream.js:50:51)
      at new  (/root/.bun/install/global/node_modules/union/lib/routing-stream.js:30:17)
      at requestHandler (/root/.bun/install/global/node_modules/union/lib/core.js:27:25)
      at emit (node:events:98:22)
      at onNodeHTTPRequest (node:_http_server:367:22)


Bun v1.3.11 (Linux x64)

After the error log, this process is self-terminated.

Other information
Dominant language
JavaScript
Stars
14.2k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from http-party/http-server

All issues in http-party/http-server

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.