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

Error: UNHANDLED REJECTION write EPIPE #28011

Closed
jack0wsky opened this issue Nov 12, 2020 · 100 comments · Fixed by #32311 or #32744
Closed

Error: UNHANDLED REJECTION write EPIPE #28011

jack0wsky opened this issue Nov 12, 2020 · 100 comments · Fixed by #32311 or #32744
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@jack0wsky
Copy link

jack0wsky commented Nov 12, 2020

Description

Hello everyone!

I'm getting this error almost every time I shut down local server.

error UNHANDLED REJECTION write EPIPE


  Error: write EPIPE
  
  - child_process.js:806 ChildProcess.target._send
    internal/child_process.js:806:20
  
  - child_process.js:676 ChildProcess.send
    internal/child_process.js:676:19
  
  - develop.ts:130 ControllableScript.stop
    [ap-investment]/[gatsby]/src/commands/develop.ts:130:20
  
  - develop.ts:500 shutdownServices
    [ap-investment]/[gatsby]/src/commands/develop.ts:500:28
  
  - develop.ts:442 process.<anonymous>
    [ap-investment]/[gatsby]/src/commands/develop.ts:442:11

I've tried multiple times

gatsby clean
remove /node_modules and package-lock.json
npm install

but it solves problem only for some time. Don't know if it is related but when gatsby develop and dev server is running, after some saves, when I click Command + S to save changes, hot reload doesn't work and project isn't re-rendering.

Steps to reproduce

Expected result

Shuting down dev server without errors

Actual result

Throwing error mentioned above and hot reload not working.

Environment

  System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.14.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 86.0.4240.193
    Firefox: 82.0.3
    Safari: 14.0
  npmPackages:
    gatsby: ^2.25.3 => 2.25.4 
    gatsby-alias-imports: ^1.0.6 => 1.0.6 
    gatsby-image: ^2.4.21 => 2.4.21 
    gatsby-plugin-postcss: ^3.0.4 => 3.0.4 
    gatsby-plugin-sass: ^2.4.2 => 2.4.2 
    gatsby-plugin-sharp: ^2.7.1 => 2.7.1 
    gatsby-plugin-tinacms: ^0.32.0 => 0.32.0 
    gatsby-source-filesystem: ^2.4.2 => 2.4.2 
    gatsby-tinacms-git: ^0.32.0 => 0.32.0 
    gatsby-tinacms-json: ^0.32.0 => 0.32.0 
    gatsby-tinacms-remark: ^0.32.1 => 0.32.1 
    gatsby-transformer-remark: ^2.9.2 => 2.9.2 
    gatsby-transformer-sharp: ^2.5.21 => 2.5.21 
  npmGlobalPackages:
    gatsby-cli: 2.12.117
    gatsby: 2.25.3

@jack0wsky jack0wsky added the type: bug An issue or pull request relating to a bug in Gatsby label Nov 12, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Nov 12, 2020
@LekoArts LekoArts added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 16, 2020
@github-actions
Copy link

github-actions bot commented Dec 6, 2020

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 6, 2020
@jamo
Copy link
Contributor

jamo commented Dec 6, 2020

@jack0wsky try updating to a more recent version of gatsby (as of writing this we are at 2.28.0).
Not fully sure if the underlying issue was fully fixed but I haven't run into this for a while with a fresh gatsby version.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 7, 2020
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 27, 2020
@hronchetti
Copy link

@jack0wsky try updating to a more recent version of gatsby (as of writing this we are at 2.28.0).
Not fully sure if the underlying issue was fully fixed but I haven't run into this for a while with a fresh gatsby version.

Worked for me!

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 31, 2020
@aravind-eng
Copy link

We are still seeing this issue with the latest gatsby

ERROR

UNHANDLED REJECTION write EPIPE

Error: write EPIPE

  • child_process.js:806 ChildProcess.target._send
    internal/child_process.js:806:20

  • child_process.js:676 ChildProcess.send
    internal/child_process.js:676:19

  • develop.ts:130 ControllableScript.stop
    [bigfig]/[gatsby]/src/commands/develop.ts:130:20

  • develop.ts:500 shutdownServices
    [bigfig]/[gatsby]/src/commands/develop.ts:500:28

  • develop.ts:442 process.
    [bigfig]/[gatsby]/src/commands/develop.ts:442:11

npmPackages:
gatsby: ^2.26.1 => 2.26.1
gatsby-image: ^2.5.0 => 2.5.0
gatsby-plugin-manifest: ^2.6.1 => 2.6.1
gatsby-plugin-offline: ^3.4.0 => 3.4.0
gatsby-plugin-react-helmet: ^3.4.0 => 3.4.0
gatsby-plugin-sharp: ^2.8.0 => 2.8.0
gatsby-plugin-styled-components: ^3.8.0 => 3.8.0
gatsby-source-filesystem: ^2.5.0 => 2.5.0
gatsby-transformer-sharp: ^2.6.0 => 2.6.0
npmGlobalPackages:
gatsby-cli: 2.7.29

@karlhorky
Copy link
Contributor

Yes, this error also happens for me every time I shut down using ctrl-C on macOS.

Demo repo:

https://github.com/upleveled/gatsby-serverside-auth0/tree/main/packages/gatsby-website

@sol-idsnake
Copy link

Same thing happens on Win10:

    "gatsby": "^2.31.1",
    "gatsby-image": "^2.10.0",
    "gatsby-plugin-google-analytics": "^2.10.0",
    "gatsby-plugin-react-helmet": "^3.9.0",
    "gatsby-plugin-sass": "^3.1.0",
    "gatsby-plugin-sharp": "^2.13.4",
    "gatsby-plugin-sitemap": "^2.11.0",
    "gatsby-source-filesystem": "^2.10.0",
    "gatsby-source-wordpress-experimental": "^7.0.3",
    "gatsby-transformer-sharp": "^2.11.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",

"develop": "gatsby develop -H=0.0.0.0",

Node: v14.15.4
npm: 6.14.10

@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 22, 2021
@siemah
Copy link

siemah commented Feb 22, 2021

hey @jack0wsky , @karlhorky , @sol-idsnake and @aravind-tc there is nothing wrong with GatsbyJS its how NodeJS handle piping data into closed streams, the error might be caused when the NodeJS event loop didn't clean-up closed TCP connections from the HTTP connection pool and then the NodeJS runtime attempted to use the closed TCP connection.

@karlhorky
Copy link
Contributor

Hmm... but I think there's a way to hook into the SIGINT event that is triggered by ctrl-C and prevent these types of things. I remember fixing a similar issue with logging output from a process not stopping on SIGINT a few years ago. I think this can be fixed in Gatsby itself.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 22, 2021
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 14, 2021
@karlhorky
Copy link
Contributor

hello stalebot

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 15, 2021
@thelovesmith
Copy link

Has anyone figured out any solutions for this error? IM getting the same EPIPE error every time I shut down my local server.

@Jim-Horn
Copy link

I almost always get that same error. I'm using iTerm & zsh. Wondering if it's related to either of those.

@rptomey
Copy link

rptomey commented Apr 20, 2021

I get this error, too. Happens every time I use control+c to shut down gatsby develop mode.

@github-actions
Copy link

github-actions bot commented Jun 8, 2021

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 8, 2021
@kb1995
Copy link

kb1995 commented Feb 23, 2022

So I'm running two Gatsby websites, both with latest package upgrades and both running on Netlify.

One of the websites uses the new gatsby-plugin-image while the other one uses a mixture of the new and the old (gatsby-image) plugins. Several of the pages have a large amount of images utilising the gatsby-image which seem to overload the memory capacity of Netlify.

The website where I'm only using gatsby-plugin-image doesn't have this problem at all, while the other website experiences this error about 25% of the builds.

@stevepepple
Copy link

I'm also seeing this issue on Netlify with any version of Gatsby, most recently @4.7.1 I emailed Netlify support about this issue, and they said it's because of memory use while processing sharp images. However, I see that the image processing job appears to complete successfully:

4:50:53 PM: success run queries in workers - 134.799s - 2149/2149 15.94/s
**4:51:50 PM: success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 787.835s - 1076/1076 1.37/s**
4:51:50 PM: error UNHANDLED EXCEPTION write EPIPE
4:51:50 PM: 
4:51:50 PM: 
4:51:50 PM:   Error: write EPIPE
4:51:50 PM:   
4:51:50 PM:   - child_process.js:841 ChildProcess.target._send
4:51:50 PM:     internal/child_process.js:841:20
4:51:50 PM:   
4:51:50 PM:   - child_process.js:712 ChildProcess.target.send
4:51:50 PM:     internal/child_process.js:712:19
4:51:50 PM:   
4:51:50 PM:   - index.js:291 WorkerPool.sendMessage
4:51:50 PM:     [site]/[gatsby-worker]/dist/index.js:291:19
4:51:50 PM:   
4:51:50 PM:   - worker-messaging.ts:22 
4:51:50 PM:     [site]/[gatsby]/src/utils/jobs/worker-messaging.ts:22:22

I did want to share that I reduce the amount and size of images that we were processing (from Wordpress). In particular, I was able to consolidate duplicate images from SEO and other fields. I also make sure we didn't have any large images in terms of resolution width and bytes. After that our build time was drastically reduced by half and the Gatsby 4 builds in Netlify no longer time out.

@MuhammadHadiofficial
Copy link

Still facing the same issue.
image
Any solution?

@kb1995
Copy link

kb1995 commented Feb 25, 2022

@MuhammadHadiofficial Migrate away from gatsby-image

@MuhammadHadiofficial
Copy link

@kb1995 Hi, I didn't get it what are other options?

@stevepepple
Copy link

@MuhammadHadiofficial Migrate away from gatsby-image

That's not really a solution, since Gatsby image is a core part of what makes Gatsby nice.

@Skil3e
Copy link

Skil3e commented Feb 25, 2022

I ended up resizing and resaving my images and it builds successfully now. What seems weird to me is that I have another site with a lot more images that never had this issue. For reference the site that failed had a total of 25 images.

@MuhammadHadiofficial
Copy link

@Skil3e can you tell me the actual difference between the size of your image before and after resizing was the size difference much larger?

@stevepepple
Copy link

@MuhammadHadiofficial Migrate away from gatsby-image

That's not really a solution, since Gatsby image is a core part of what makes Gatsby nice.

@Skil3e
Copy link

Skil3e commented Feb 26, 2022

@MuhammadHadiofficial not really big size difference more on reduce of file size, somewhere between 100kb to 500kb smaller filesies, As i said before though it seems weird as there were not too many or too big images to begin with.

@kb1995
Copy link

kb1995 commented Feb 26, 2022

@MuhammadHadiofficial Migrate away from gatsby-image

That's not really a solution, since Gatsby image is a core part of what makes Gatsby nice.

You can migrate from gatsby-image (a deprecated API) to gatsby-plugin-image (new API). You can still continue using Gatsby for what makes it nice

@MuhammadHadiofficial
Copy link

I'm using gatsby-plugin-image already on previous plugin we didn't had this issue after migrating to gatsbyv4 and new image plugin we started to face these memory related issues.

@stevepepple
Copy link

@MuhammadHadiofficial Migrate away from gatsby-image

That's not really a solution, since Gatsby image is a core part of what makes Gatsby nice.

You can migrate from gatsby-image (a deprecated API) to gatsby-plugin-image (new API). You can still continue using Gatsby for what makes it nice

Oh, I see what you mean. That said, I believe the same memory issues happen with new API (gatsby-plugin-image). I'd not seen the issue after reducing image size, but a few new Wordpress images triggered this issue just the other day. We removed all instances of gatsby-image

@MuhammadHadiofficial
Copy link

@stevepepple if you removed the gatsbyimagedats?
Then how you are rendering the images?

@stevepepple
Copy link

@stevepepple if you removed the gatsbyimagedats? Then how you are rendering the images?

It's a little confusing. I removed gatsby-image but I'm using gatsby-plugin-image

@panzacoder
Copy link
Contributor

Hi @stevepepple and @MuhammadHadiofficial you should reference the migration doc: https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide/

GatsbyImage originally came pre-baked into Gatsby v1-2, but was later deprecated in favor of the plugin approach, which has a simpler API and some additional functionality (including somewhat better performance for page visitors).

Unfortunately I do not believe that it is a solution to this particular problem.

@MuhammadHadiofficial
Copy link

Hi @stevepepple and @MuhammadHadiofficial you should reference the migration doc: https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide/

GatsbyImage originally came pre-baked into Gatsby v1-2, but was later deprecated in favor of the plugin approach, which has a simpler API and some additional functionality (including somewhat better performance for page visitors).

Unfortunately I do not believe that it is a solution to this particular problem.

Hi @panzacoder , I've already migrated to latest Gatsby version4 and latest Gatsby image plugin and ran the migration script also.
Problem is this new plugin uses more resources as compared to what netlify provides and it goes out of memory and process gets killed.

@panzacoder
Copy link
Contributor

Hi @panzacoder , I've already migrated to latest Gatsby version4 and latest Gatsby image plugin and ran the migration script also. Problem is this new plugin uses more resources as compared to what netlify provides and it goes out of memory and process gets killed.

Thanks for clarifying the state of your project. I have also had the same issues with Netlify, and in general Gatsby v4 (I actually ran into memory issues running on Gatsby Cloud as well.

I'm assuming there are deficiencies in our build step that need to be addressed, but I don't have time to figure that our right now, so I migrated down to Gatsby v3. I believe there was only one plugin I had to update to get stable builds again, but YMMV.

I am hoping to have time to dig into our performance build issues sooner-than-later but right now our marketing team requires focus elsewhere.

What's frustrating for me overall is that this seems to be a pretty big issue (memory usage in build step) but there's not a clear path forward on figuring out what is causing it, whether it's a framework issue, a plugin issue, or a custom code issue.

TL;DR: Revert to Gatsby v3 until you have time/budget to diagnose your build performance

@stevepepple
Copy link

Thanks @panzacoder. Why is this issue closed though? I don't believe downgrading is an adequate work around for many who need to use the latest version of Gatsby.

@bybyers
Copy link

bybyers commented Mar 11, 2022

This issue should not be closed. Image processing works on my local environment but not Netlfiy. Something that started happening after updating Gatsby.

@stevepepple
Copy link

stevepepple commented Mar 11, 2022

Btw, there appears to be another issue for the same problem along with my latest update/workaround for Netlify. Curious if it helps your instance @byebyers

#35055 (comment)

@hari-s
Copy link

hari-s commented Mar 31, 2022

I was facing this issue while deploying with netlify with gatsby version 4.11.0,
it worked for me while I down graded gatsby version to 4.1.3

@jdahdah
Copy link
Contributor

jdahdah commented Mar 31, 2022

This issue recently started happening to me across three client projects. One of which was already upgraded to Gatsby v4 before it started and can't be rolled back to v3. The other one is waiting for a fix so that the upgrade can be completed. But the most clear demonstration of this issue is the most recent project, which I started about a week ago (so of course it uses v4). It only has about 14 images that are a few hundred KBs each (but reused in a few places at different sizes), across 20 pages. Builds are failing left and right and only sporadically work. It's extremely unreliable. I don't think it's an issue of inefficient coding, I am writing fairly idiomatic code as recommended in the docs.

There is a major issue going on with Gatsby v4 and Netlify. When will it be taken seriously?

success write out requires - 0.003s
6:50:51 PM: success Building production JavaScript and CSS bundles - 25.772s
6:51:12 PM: success Building HTML renderer - 20.601s
6:51:12 PM: success Execute page configs - 0.069s
6:51:12 PM: success Caching Webpack compilations - 0.001s
6:51:15 PM: success run queries in workers - 2.929s - 29/29 9.90/s
6:51:28 PM: success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 15.818s - 40/40 2.53/s
6:51:28 PM: error UNHANDLED EXCEPTION write EPIPE
6:51:28 PM: 
6:51:28 PM: 
6:51:28 PM:   Error: write EPIPE
6:51:28 PM:   
6:51:28 PM:   - child_process:866 ChildProcess.target._send
6:51:28 PM:     node:internal/child_process:866:20
6:51:28 PM:   
6:51:28 PM:   - child_process:739 ChildProcess.target.send
6:51:28 PM:     node:internal/child_process:739:19
6:51:28 PM:   
6:51:28 PM:   - index.js:298 WorkerPool.sendMessage
6:51:28 PM:     [repo]/[gatsby-worker]/dist/index.js:298:19
6:51:28 PM:   
6:51:28 PM:   - worker-messaging.ts:22 
6:51:28 PM:     [repo]/[gatsby]/src/utils/jobs/worker-messaging.ts:22:22
6:51:28 PM:   
6:51:28 PM: 
6:51:28 PM: not finished Merge worker state - 0.044s
6:51:29 PM: ​
6:51:29 PM: ────────────────────────────────────────────────────────────────
6:51:29 PM:   "build.command" failed                                        
6:51:29 PM: ────────────────────────────────────────────────────────────────
6:51:29 PM: ​
6:51:29 PM:   Error message
6:51:29 PM:   Command failed with exit code 1: gatsby build (https://ntl.fyi/exit-code-1)
6:51:29 PM: ​
6:51:29 PM:   Error location
6:51:29 PM:   In build.command from netlify.toml:
6:51:29 PM:   gatsby build

@bybyers
Copy link

bybyers commented Mar 31, 2022

The thing that worked for me was pinning my Gatsby version to 4.7.2. I changed it in my package.json then ran npm install. The issue seems to be with the latest version.

@wktk
Copy link
Contributor

wktk commented Apr 1, 2022

In the case of the issue with v4.8+ and Netlify, #35055 is currently ongoing.

@MuhammadHadiofficial
Copy link

@panzacoder any updates on the issue?

@andrelandgraf
Copy link

andrelandgraf commented Apr 8, 2022

I am on Gatsby v^4.11.2. The issue only came up for me after I changed an image in my repository. I am seeing this issue now on my Netlify build as well and it seems to be connected to gatsby-plugin-image. Image file size seems to not affect the issue. I reduced the image file size to 2 MB from 24 MB but the issue is still occurring.

@knupel
Copy link

knupel commented Apr 23, 2022

Same isssue when I deploy on Netlify with

"gatsby": "^4.12.1",
"gatsby-plugin-image": "^2.12.1",
"gatsby-transformer-sharp": "^4.12.1",
"gatsby-plugin-sharp": "^4.12.1",

@bybyers
Copy link

bybyers commented Apr 26, 2022

Not sure if this will help but I found that this error had a lot to do with my client's use of Headless WordPress (I joined after it was set up). For example:

Changing an image on a page or post may not actually remove the original and replace it with the newer version. Instead, WordPress attaches the new image with the old one and thinks the post now has a gallery. It will still serve the correct image to the live page and not an array. However, Gatsby will still at build time run its image optimization on all attached images, regardless if they are being used. To remedy this I recommend going through your media library and detach any extra images you may have.

Another is if WordPress has to deal with large asset sizes like gifs or video files. When these are passed to Gatsby at build time, the WordPress server gets overloaded and the error is thrown. At least it was for me anyway. I basically had to talk to the team to be aware of what kind of assets they are using because WordPress as a CMS may not be able to handle sending these to Gatsby. We had to replace them with more optimized versions.

Its super lame and if you have a chance I recommend steering clear of Headless WordPress. It's issues run deep in terms of how it integrates on the Jamstack.

@ascorbic
Copy link
Contributor

Hey. This is a duplicate of #35055 , which now has a fix. If you update to gatsby@4.13.1 then it should fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.