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

Http-proxy crashes my react site RANDOMLY #1627

Open
tarik-besic opened this issue Feb 23, 2023 · 2 comments
Open

Http-proxy crashes my react site RANDOMLY #1627

tarik-besic opened this issue Feb 23, 2023 · 2 comments

Comments

@tarik-besic
Copy link

Our site is using Nodejs v.12
We are using npm run start which just executes npm-run-all -p watch-css start-js
Our problem is that our app compiles and after random amount of time (somtimes its instantly, sometimes it's after 10-20 seconds) crashes and I get this error...

Any idea on why is this happening?
We have setuped proxy in our package.json like this:
"proxy": "http://localhost:3000",

Compiled successfully!

You can now view frontend in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.4.127:3000/

Note that the development build is not optimized.
To create a production build, use yarn build.

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:399:19)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at ClientRequest.<anonymous> (/home/ruby/Desktop/work/marshall/frontend/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js:115:16)
    at ClientRequest.emit (events.js:314:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:601:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:122:17)
    at Socket.socketOnData (_http_client.js:474:22)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Socket instance at:
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at onwriteError (_stream_writable.js:418:5)
    at onwrite (_stream_writable.js:445:5)
    at doWrite (_stream_writable.js:399:11)
    at writeOrBuffer (_stream_writable.js:387:5)
    [... lines matching original stack trace ...]
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  code: 'ERR_STREAM_DESTROYED'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 start-js: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 start-js script.
@trusktr
Copy link

trusktr commented Dec 3, 2023

If you do this:

response.end('some message')

// ... later, with the *same* response ...
response.end('another message')

you will get that error. Make you you write response.end like this:

response.end('some message')
return // do not handle the request anymore!

@tarik-besic
Copy link
Author

If you do this:

response.end('some message')

// ... later, with the *same* response ...
response.end('another message')

you will get that error. Make you you write response.end like this:

response.end('some message')
return // do not handle the request anymore!

Isn't that an issue on the npm package?
Since the issue should be on their side?

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

No branches or pull requests

2 participants