Skip to content
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

Allow statusCode and statusMessage to be changed on IncomingMessage #8368

Closed
wants to merge 2 commits into from

Conversation

Electroid
Copy link
Contributor

What does this PR do?

ngrok is changing the statusCode and statusMessage on incoming requests, which fixes the following issue:

1212 |         this[kStopReading] = true;
1213 |         if (!(error instanceof RequestError)) {
1214 |             error = new RequestError(error.message, error, this);
1215 |         }
1216 |         const typedError = error;
1217 |         const { response } = typedError;
                    ^
RequestError: Attempted to assign to readonly property.
 code: "ERR_GOT_REQUEST_ERROR"

Unfortunately, ngrok still doesn't work. (it hangs instead of error) But I figured we should get this fix out anyway.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

There are tests.

Copy link
Contributor

return this[statusMessageSymbol] ?? STATUS_CODES[this[reqSymbol].status];
},
set(value) {
this[statusMessageSymbol] = value;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context:

Node http2 uses a symbol called 'state':
https://github.com/nodejs/node/blob/main/lib/internal/http2/compat.js#L71

Related to IncomingMessage however Node uses a data property (not accessor):
https://github.com/nodejs/node/blob/main/lib/_http_incoming.js#L88

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we should just set the property on the object and not use a getter/setter

Copy link
Contributor

❌🪟 @autofix-ci[bot], there are 12 test regressions on Windows x86_64

  • test\cli\inspect\inspect.test.ts
  • test\js\bun\shell\bunshell-instance.test.ts
  • test\js\bun\shell\bunshell.test.ts
  • test\js\bun\shell\commands\rm.test.ts
  • test\js\bun\shell\lazy.test.ts
  • test\js\bun\shell\leak.test.ts
  • test\js\bun\shell\lex.test.ts
  • test\js\bun\util\stringWidth.test.ts
  • test\js\node\events\events-cjs.test.js
  • test\js\web\timers\performance.test.js
  • test\regression\issue\08095.test.ts
  • test\regression\issue\08258.test.ts

Full Test Output

@svemat01
Copy link

Any plans for this PR or is it ready to merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants