Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !12731

Fix 'ERR_STREAM_WRITE_AFTER_END' error in proxy

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Administrator requested to merge github/fork/jamirvin/main into main Sep 14, 2022
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: jamirvin

In my project when using the CRA proxy configuration my team has started to hit transient ERR_STREAM_WRITE_AFTER_END errors that crash the dev server. This would result in an stack trace like the following:

[wds] Proxy error: Could not proxy request /api/graphql from localhost:3000 to http://localhost:8080/.
[wds] See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
[wds]
[wds] events.js:377
[wds]       throw er; // Unhandled 'error' event
[wds]       ^
[wds]
[wds] Error [ERR_STREAM_WRITE_AFTER_END]: write after end
[wds]     at new NodeError (internal/errors.js:322:7)
[wds]     at writeAfterEnd (_http_outgoing.js:694:15)
[wds]     at ServerResponse.end (_http_outgoing.js:815:7)
[wds]     at ServerResponse.end (project_root/node_modules/compression/index.js:107:21)
[wds]     at ProxyServer.<anonymous> (project_root/node_modules/react-dev-utils/WebpackDevServerUtils.js:288:9)
[wds]     at ProxyServer.emit (project_root/http-proxy/node_modules/eventemitter3/index.js:210:27)
[wds]     at ClientRequest.proxyError (project_root/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:165:18)
[wds]     at ClientRequest.emit (events.js:400:28)
[wds]     at TLSSocket.socketErrorListener (_http_client.js:475:9)
[wds]     at TLSSocket.emit (events.js:400:28)
[wds] Emitted 'error' event on ServerResponse instance at:
[wds]     at writeAfterEndNT (_http_outgoing.js:753:7)
[wds]     at processTicksAndRejections (internal/process/task_queues.js:83:21) {
[wds]   code: 'ERR_STREAM_WRITE_AFTER_END'
[wds] }

I've not been able to determine what is ending the request before it gets to the 'onError' function (it seems to correspond with making changes that trigger a reload at the same time as a network error), but I've confirmed that reproducing the CRA proxy using setupProxy.js with this change resolves the crash.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jamirvin/main